MATLAB Answers


How to Capture objects in big image and divided them to small images?

Asked by warinthorn Kiadti on 8 Feb 2012
Latest activity Commented on by Image Analyst
on 4 Jan 2015
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.


Sign in to comment.


2 Answers

Answer by Chandra Kurniawan on 12 Feb 2012
 Accepted Answer

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});


Show 1 older comment
Of course not. Did you see the first line of his answer that said "This code works just for this image only" ? And besides, his code does not do texture segmentation which is what you need.
I just realized it. My mistake. Sorry. So, may I know how can solve my problem? What should I do now since I a newbie in image processing.
Look at section 8.8 here. Pick one, code it up, then create a brand new discussion and attach your code, your image, and your question.

Sign in to comment.

Answer by warinthorn Kiadti on 12 Feb 2012

Thank you very much. this is great. XX


Sign in to comment.