Question
Hi, I stuck at my study now. I have one example image. From this image, I would like to separate these five small objects in the picture to be five small images. How can I do this. I need your help please. I am looking forward to hear from you. Thank you very much.
Related Questions
Expert Answer
Prashant Kumar
PhD Expert
Answered Nov 20, 2025
This code works just for this image only
Irgb = imread('b653er.jpg');
Igray = rgb2gray(Irgb);
Ibw = im2bw(Igray,graythresh(Igray));
Ifill = imfill(Ibw,'holes');
%clear the lines
Ihor = imopen(Ifill,strel('line',5,0));
Iver = imopen(Ihor,strel('line',5,90));
Ilabel = bwlabel(Iver);
stat = regionprops(Ilabel,'BoundingBox');
for x = 1 : numel(stat)
bb = stat(x).BoundingBox;
Icrop{x} = imcrop(Irgb,bb);
subplot(numel(stat),1,x); imshow(Icrop{x});
end

Have a different question? Ask here