loading
3CommentsJoined January 29th, 2017

Tell us about yourself!

Complete Your Profile
  • Su MonA followed min151 month ago
  • Image Processing and Counting using MATLAB

    clc;clearvars;close all;imtool close all; % Close all imtool figures.workspace;format longg;format compact;fontSize = 20;tic;% Read imageoriginal = imread('F04U2MPIXQG3WQS.LARGE.jpeg');figure,imshow(original)% RGB componentR=original(:,:,1);G=original(:,:,2);B=original(:,:,3);figure,imshow(R)figure,imshow(G)figure,imshow(B)% Thresholding% Select Red compoentlevel=graythresh(R);binary=im2bw(R,level);figure,imshowpair(original,binary,'montage')% Use Morphological Operations erosion=imerode(binary,strel('disk',2));figure,imshow(erosion)% Use Watershed segmentation D = bwdist(erosion);figureimshow(D,[],'InitialMagnification','fit')title('Distance transform of ~bw')D = -D;D(~erosion) = -Inf;L = watershed(D);Lrgb = label2rgb(L,'jet',[.5 .5 .5]);figureimshow(Lrgb,'InitialMagnification','fit')...see more »clc;clearvars;close all;imtool close all; % Close all imtool figures.workspace;format longg;format compact;fontSize = 20;tic;% Read imageoriginal = imread('F04U2MPIXQG3WQS.LARGE.jpeg');figure,imshow(original)% RGB componentR=original(:,:,1);G=original(:,:,2);B=original(:,:,3);figure,imshow(R)figure,imshow(G)figure,imshow(B)% Thresholding% Select Red compoentlevel=graythresh(R);binary=im2bw(R,level);figure,imshowpair(original,binary,'montage')% Use Morphological Operations erosion=imerode(binary,strel('disk',2));figure,imshow(erosion)% Use Watershed segmentation D = bwdist(erosion);figureimshow(D,[],'InitialMagnification','fit')title('Distance transform of ~bw')D = -D;D(~erosion) = -Inf;L = watershed(D);Lrgb = label2rgb(L,'jet',[.5 .5 .5]);figureimshow(Lrgb,'InitialMagnification','fit')title('Watershed transform of D')figure,imshow(imfuse(erosion,Lrgb))axis([])bw2 = ~bwareaopen(~erosion, 10);imshow(bw2)D = -bwdist(~erosion);figure,imshow(D,[])Ld = watershed(~D);figure,imshow(label2rgb(Ld))bw2 = erosion;bw2(Ld == 0) = 0;mask = imextendedmin(D,2);D2 = imimposemin(D,mask);Ld2 = watershed(D2);bw3 = erosion;bw3(Ld2 == 0) = 0;figure,imshowpair(original,bw3,'montage');title('Watershed Segmentation','FontSize',fontSize)% labelling s=regionprops(logical(bw3),'Centroid','Area','Eccentricity','Perimeter');hold onfor k=1:numel(s) c=s(k).Centroid; text(c(1),c(2),sprintf('%d',k),... 'HorizontalAlignment','center',... 'VerticalAlignment','middle');endhold offNum = numel(s);message= sprintf('You have counted %i Strawberries',Num);h=msgbox(message);

    Dear min15,I developed one code for you.Although it is not perfect,I hope you can get something from this.Enjoy it! Please your knowledge and develope it more

    Dear min15,I have developed one code for your image.Although it is not perfect, I hope you can get something from this.Keep in touch! Enjoy your strawberries !Here is the code for youclc;clearvars;close all;imtool close all; % Close all imtool figures.workspace;format longg;format compact;fontSize = 20;tic;% Read imageoriginal = imread('F04U2MPIXQG3WQS.LARGE.jpeg');figure,imshow(original)title('Original Image','FontSize',fontSize);% RGB componentR=original(:,:,1);G=original(:,:,2);B=original(:,:,3);figure,imshow(R)title('Red Component Image','FontSize',fontSize);figure,imshow(G)title('Green Component Image','FontSize',fontSize);figure,imshow(B)title('Blue Component Image','FontSize',fontSize);% Thresholding% Select Red compoentlevel=graythresh(R);binary=im2bw(R,level);figure,imshow(bina...see more »Dear min15,I have developed one code for your image.Although it is not perfect, I hope you can get something from this.Keep in touch! Enjoy your strawberries !Here is the code for youclc;clearvars;close all;imtool close all; % Close all imtool figures.workspace;format longg;format compact;fontSize = 20;tic;% Read imageoriginal = imread('F04U2MPIXQG3WQS.LARGE.jpeg');figure,imshow(original)title('Original Image','FontSize',fontSize);% RGB componentR=original(:,:,1);G=original(:,:,2);B=original(:,:,3);figure,imshow(R)title('Red Component Image','FontSize',fontSize);figure,imshow(G)title('Green Component Image','FontSize',fontSize);figure,imshow(B)title('Blue Component Image','FontSize',fontSize);% Thresholding% Select Red compoentlevel=graythresh(R);binary=im2bw(R,level);figure,imshow(binary)title('Thresholed Image','FontSize',fontSize);% Use Morphological Operations erosion=imerode(binary,strel('disk',2));figure,imshow(erosion)title('Eroded Image','FontSize',fontSize);% Use Watershed segmentation D = bwdist(erosion);figureimshow(D,[],'InitialMagnification','fit')title('Distance transform of ~bw')D = -D;D(~erosion) = -Inf;L = watershed(D);Lrgb = label2rgb(L,'jet',[.5 .5 .5]);figureimshow(Lrgb,'InitialMagnification','fit')title('Watershed transform of D')figure,imshow(imfuse(erosion,Lrgb))axis([])bw2 = ~bwareaopen(~erosion, 10);imshow(bw2)D = -bwdist(~erosion);figure,imshow(D,[])Ld = watershed(~D);figure,imshow(label2rgb(Ld))bw2 = erosion;bw2(Ld == 0) = 0;mask = imextendedmin(D,2);D2 = imimposemin(D,mask);Ld2 = watershed(D2);bw3 = erosion;bw3(Ld2 == 0) = 0;figure,imshow(erosion);title('Watershed Segmentation','FontSize',fontSize)% labelling figure,imshow(original);title('Labelling','FontSize',fontSize)s=regionprops(logical(bw3),'Centroid','Area','Eccentricity','Perimeter');hold onfor k=1:numel(s)c=s(k).Centroid;text(c(1),c(2),sprintf('%d',k),...'HorizontalAlignment','center',...'VerticalAlignment','middle');endhold offNum = numel(s);message= sprintf('You have counted %i Strawberries',Num);h=msgbox(message);

    View Instructable »