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

22 views (last 30 days)

Show older comments

##### 0 Comments

### Accepted Answer

Dima Lisin
on 13 Oct 2015

Edited: Dima Lisin
on 25 Oct 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, :);

### More Answers (2)

Thorsten
on 12 Oct 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 Comments

Thorsten
on 12 Oct 2015

C = B(ind1,ind2,:);

where ind1, ind2 are the vectors ob indices that define the region.

Image Analyst
on 12 Oct 2015

##### 2 Comments

Image Analyst
on 12 Oct 2015

Sorry - I don't have the Computer Vision System Toolbox. Perhaps Dima will answer you.

### See Also

### Community Treasure Hunt

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

Start Hunting!