How to crop an image and automatically crop another image with same positioning?
Show older comments
i have a GUI like this

how to crop an image from axes, when i click the "crop" button and automatically crop with same position in another image when i click "crop2" button, thanks before,
Answers (2)
Sean de Wolski
on 23 Dec 2014
I = imread('cameraman.tif');
II = imread('peppers.png');
II = imresize(II,size(I)); % same size
[Icrop,rect] = imcrop(I);
IIcrop = imcrop(II,rect);
subplot(1,2,1)
imshow(Icrop)
subplot(1,2,2)
imshow(IIcrop)
Chad Greene
on 22 Dec 2014
Edited: Chad Greene
on 22 Dec 2014
0 votes
Those look like Landsat 8 images. With geoimread, you can specify a bounding box of lat/lons or map x/y coordinates and only load pixels corresponding to that bounding box.
Using geoimread, the user could click a "select region" button which you could program to call inputm. When the user's done entering points, she could click "crop" and coordinates from inputm could then be entered into geoimread.
4 Comments
mike
on 23 Dec 2014
Chad Greene
on 24 Dec 2014
When the user clicks a bounding box in image A (calling inputm), use those coordinates to load only that region in images A and B with geoimread.
mike
on 25 Dec 2014
sandra viaña borja
on 14 Dec 2017
Hello Mike How did you solve this? I have the same problem, and when I get the second image cropped, there is a lillte spatial difference between both images. I will appreciate if you could help me.
Categories
Find more on Image Arithmetic 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!