Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Image Analyst
Image Analyst el 1 de Jun. de 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 comentarios
Indunie Florence
Indunie Florence el 1 de Jun. de 2014
Editada: Indunie Florence el 1 de Jun. de 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 el 1 de Jun. de 2014
As you said, bwconvhull method solve the problem.. thank you thank you very much...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Geometric Transformation and Image Registration en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by