center crop image based on other image dimension
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/985585/image.png)
When I try to do it in MATLAB it fails.
The polygon-
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/985590/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/985595/image.png)
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):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/985600/image.png)
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 comentarios
DGM
el 4 de Mayo de 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?
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!