How to select boundary box?

2 次查看(过去 30 天)
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
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
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-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
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?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by