How to crop an image A which is a subset of an image B
2 次查看(过去 30 天)
显示 更早的评论
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 ?
0 个评论
采纳的回答
Dima Lisin
2015-10-13
编辑:Dima Lisin
2015-10-25
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 个评论
Dima Lisin
2015-10-25
编辑:Dima Lisin
2015-10-25
Sorry, I've fixed the answer. Use round(), and switch top:bottom and left:right.
更多回答(2 个)
Thorsten
2015-10-12
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 个评论
Thorsten
2015-10-12
C = B(ind1,ind2,:);
where ind1, ind2 are the vectors ob indices that define the region.
Image Analyst
2015-10-12
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 个评论
Image Analyst
2015-10-12
Sorry - I don't have the Computer Vision System Toolbox. Perhaps Dima will answer you.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computer Vision with Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!