in the code attached, i want all the segmented rice images to appear in the form of subplot but this code keeps me giving the output as the last rice image in subplot.Thanks in advance.(this code was developed with the help of some codes present on the internet)
a=imread('r-1121.jpeg');
figure,imshow(a);
title('original image');
I1 = rgb2gray(a);
I1=imsharpen(I1);
I=medfilt2(I1);
b=imbinarize(I);
figure,
imshow(b);
c=imfill(b,'holes');
label=bwlabel(c);
for j=1:max(max(label))
[row,col]=find(label==j);
len=max(row)-min(row)+2;
breadth=max(col)-min(col)+2;
target=uint8(zeros([len breadth] ));
sy=min(col)-1;
sx=min(row)-1;
for i=1:size(row,1)
x=row(i,1)-sx;
y=col(i,1)-sy;
target(x,y)=a(row(i,1),col(i,1));
end
for k=1:25
mytitle=strcat('Rice number: ',num2str(j));
ax=subplot(1,25,k);
imshow(target);
end
end
Best Answer