Image processing is an important tool of MATLAB. We can quite easily do the image processing in it using Image Processing toolbox so you need to make sure that your MATLAB must have Image processing toolbox before running this code. You should also have a look at these MATLAB Image Processing Projects. So, let's start with the project.
data = imread('TEP.jpg'); diff_im = imsubtract(data(:,:,2), rgb2gray(data)); %Use a median filter to filter out noise diff_im = medfilt2(diff_im, [3 3]); diff_im = im2bw(diff_im,0.18); diff_im = bwareaopen(diff_im,300); bw = bwlabel(diff_im, 8); stats = regionprops(bw, 'BoundingBox', 'Centroid'); % Display the image imshow(data) hold on for object = 1:length(stats) bb = stats(object).BoundingBox; bc = stats(object).Centroid; rectangle('Position',bb,'EdgeColor','r','LineWidth',2) plot(bc(1),bc(2), '-m+') a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), ' Y: ', num2str(round(bc(2))))); set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'black'); end hold of
data = imread('TEP.jpg'); diff_im = imsubtract(data(:,:,1), rgb2gray(data)); %Use a median filter to filter out noise diff_im = medfilt2(diff_im, [3 3]); diff_im = im2bw(diff_im,0.18); diff_im = bwareaopen(diff_im,300); bw = bwlabel(diff_im, 8); stats = regionprops(bw, 'BoundingBox', 'Centroid'); % Display the image imshow(data) hold on for object = 1:length(stats) bb = stats(object).BoundingBox; bc = stats(object).Centroid; rectangle('Position',bb,'EdgeColor','r','LineWidth',2) plot(bc(1),bc(2), '-m+') a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), ' Y: ', num2str(round(bc(2))))); set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'black'); end hold off
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w