How to select boundary box of 221.jpg and crop it like 222.jpg ?
221.jpg
222.jpg

 채택된 답변

Indunie Florence
Indunie Florence 2016년 4월 18일
편집: Indunie Florence 2016년 4월 18일

0 개 추천

Thanks for everyone who tried to help me. Finally I found the simple way to do it. this is a really awesome method. bwconvhull(Iout)
This is the code segment;
if true
LB = 100;
UB = 100000;
IL = bwlabel(Ifill);
R = regionprops(Ifill,'Area');
ind = find([R.Area] >= LB & [R.Area] <= UB);
Iout = ismember(IL,ind);
%Ibw1=imcomplement(Iout);
CH = bwconvhull(Iout);
%Ibw3=imcomplement(CH);
[Ilabel num] = bwlabel(CH);
Iprops = regionprops(Ilabel);
Ibox = [Iprops.BoundingBox];
Icrop = imcrop(I,Ibox);
resized=imresize(Icrop,[100 100]);
end

추가 답변 (2개)

Image Analyst
Image Analyst 2014년 6월 1일

1 개 추천

This can also be solved using the algorithm I laid out in your previous question http://www.mathworks.com/matlabcentral/answers/132000#answer_139060

댓글 수: 4

Indunie Florence
Indunie Florence 2014년 6월 2일
No it doesn't work for this input. This is a binary image. It gave an error,
rows = 3264
columns = 2448
numberOfColorBands = 1
Index exceeds matrix dimensions.
Error in test (line 38)
greenChannel = rgbImage(:, :, 2);
>>
Do you know what the line
greenChannel = rgbImage(:, :, 2);
does? It takes the second plane of the 3D image variable. So the image must be 3D. If it's 2D, like yours which has only 1 color channel in a single 2D image, you can't take the second plane and must just use the image itself. So you have to check for that.
if numberOfColorBands > 1
% It's color, take just one color channel
greenChannel = rgbImage(:, :, 2);
else
% It's monochrome, take the original image.
greenChannel = rgbImage; % It's not really RGB
end
Indunie Florence
Indunie Florence 2014년 6월 3일
편집: Indunie Florence 2016년 4월 18일
Thank you very much for helping me.I didn't know it.I have done all other things and I am stuck in cropping. It seems very simple. But I couldn't do yet.
I changed it as you said for 3 channels. Then there are no errors. But cropping is still not happened.Output is below,
Image Analyst
Image Analyst 2014년 6월 3일
You need to invert your binary image since it's darker than the background. You can either flip the > sign when doing thresholding (which is the easiest) or you can do it in a separate steps (more time consuming) binaryImage = ~binaryImage.

댓글을 달려면 로그인하십시오.

dhiaa almalki
dhiaa almalki 2016년 4월 17일

0 개 추천

if true
% code
end
if true
% code
end

댓글 수: 1

Image Analyst
Image Analyst 2016년 4월 17일
What is this for? Why don't you start your own new question?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Orange에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by