center crop image based on other image dimension
8 views (last 30 days)
Show older comments
Hi,
I have two images of the same area but with different size: an RGB and TIR format.
I'm drawing a polygon on one of them and convert it to a mask in order to get the same cropped area in the second image.
in QGIS it works: (this is the TIR on top of the RGB)

When I try to do it in MATLAB it fails.
The polygon-

To use the mask in the RGB image I resized the image in the center:
targetSize = size(TIR);
r = centerCropWindow2d(size(RGB),targetSize);
RGB = imcrop(RGB,r);
Now when I try to use the same mask on the RGB image, I get a different area (much closer):

I've also tried to do it the other way, to padd the small image with zeros around it accordingly.
Is it even possible? I want to get the same output as in the QGIS.
Any help is highly appreciated!
4 Comments
DGM
on 4 May 2022
I am really not familiar with mapping toolbox stuff at all, but maybe someone else is. I might be able to bang my head against it for a bit, but I'd really have to have the actual files to be able to have any confidence that I'm actually replicating the issue correctly.
Is trim_tif() a user-defined function?
Answers (0)
See Also
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!