How to crop an image A which is a subset of an image B

8 visualizaciones (últimos 30 días)
I have two images where image A is a subset of image B.I could with feature matching technique - identify, match and show the images as a pair. Now that i have identified and matched image A with image B. i want to clip out(crop) that exact region from image B and create a new image. How can i do this, any help is appreciated ?

Respuesta aceptada

Dima Lisin
Dima Lisin el 13 de Oct. de 2015
Editada: Dima Lisin el 25 de Oct. de 2015
If you have matched the points, then you can simply find the bounding box of the matched points:
points = round(matchedTarget.Location);
left = min(points(:, 1));
right = max(points(:, 1));
top = min(points(:, 2));
bottom = max(points(:, 2));
croppedImage = target(top:bottom, left:right, :);
  4 comentarios
dheeraj surabhi
dheeraj surabhi el 30 de Oct. de 2015
Thanks Dima. It works.
However i have a problem here. the fact that we are doing round() makes the cropped image loose a slight portion of edges as in the new image that i cropped out would have borders cut down slightly. This is happening since we are rounding the indices i guess, any idea on how can i overcome this and be able to crop the exact image?

Iniciar sesión para comentar.

Más respuestas (2)

Thorsten
Thorsten el 12 de Oct. de 2015
If I understood correctly, you have found the part in image B that is exactly like image A, and now you want to crop that part of image B. Because both are identical, the cropped image would be exactly like A, so you can just write
C = A;
  2 comentarios
Thorsten
Thorsten el 12 de Oct. de 2015
C = B(ind1,ind2,:);
where ind1, ind2 are the vectors ob indices that define the region.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 12 de Oct. de 2015
You have said you "have identified and matched image A with image B". If you did that, then you know the coordinates, for example like I did in my attached normxcorr2() demo. So simply use imcrop() after that.
  2 comentarios
Image Analyst
Image Analyst el 12 de Oct. de 2015
Sorry - I don't have the Computer Vision System Toolbox. Perhaps Dima will answer you.

Iniciar sesión para comentar.

Categorías

Más información sobre Point Cloud Processing 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