How can I crop image 1.jpg from 2.jpg in matlab(if it doesn't have boundary)?

1 次查看(过去 30 天)
How can I crop image 1.jpg from 2.jpg in matlab? Is there any function? 1.jpg is a binary image and it hasn't a boundary and noice. I use blue color for white color here to understandable.
1.jpg
2.jpg

采纳的回答

Image Analyst
Image Analyst 2014-6-1
Here are the steps (one way at least - there are several ways to do it).
  1. convert to gray with rgb2gray()
  2. threshold binaryImage = grayImage < 128
  3. call bwconvhull
  4. call bwlabel to get labeledImage
  5. call regionprops(labeledImage..... and ask for 'BoundingBox'.
  6. expand bounding box coordinates by whatever amount you want.
  7. call imcrop(originalImage, boundingBox)
That pretty much does it, except for some things like imshow() to display your progress. See if you can do it all by yourself from this point on. Let me know how it goes.
  2 个评论
Indunie Florence
Indunie Florence 2014-6-1
编辑:Indunie Florence 2014-6-1
[Ilabel num] = bwlabel(Ifinal1);
Iprops = regionprops(Ilabel);
Ibox = [Iprops.BoundingBox];
Icrop = imcrop(I,Ibox);
I used this code segment and it doesn't work.
I can't set the boundary mannually because I don't know where the objects are in the image.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by