Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Image Analyst
Image Analyst am 1 Jun. 2014
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 Kommentare
Indunie Florence
Indunie Florence am 1 Jun. 2014
Bearbeitet: Indunie Florence am 1 Jun. 2014
[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.
Indunie Florence
Indunie Florence am 1 Jun. 2014
As you said, bwconvhull method solve the problem.. thank you thank you very much...

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Geometric Transformation and Image Registration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by