MATLAB Answers

crop 2 images with the same size

1 view (last 30 days)
cyrine tijani
cyrine tijani on 30 Apr 2021
Commented: DGM on 30 Apr 2021
hi i work with matlab gui , i have 2 images i want to crop the first one and the same dimensions will be applied on the second one i hope u understand me any help please
DGM on 30 Apr 2021
I'm often reluctant to jump at assuming my answers are sufficient when people mention that they're working on a GUI. If it turns out they need help with appdesigner or something, I'm not going to be much help since appdesigner is completely broken on my system.

Sign in to comment.

Answers (1)

DGM on 30 Apr 2021
Have you looked at imcrop()? Imcrop has an interactive mode and will output the selected RECT parameter when the appropriate syntax is used.
[cropped1 rect] = imcrop(thispict);
You can then call imcrop using that parameter
[cropped2] = imcrop(thatpict,rect);
To display the images, you could do that any number of ways.
You could use subplots or tiledlayout
subplot(1,2,1); imshow(cropped1)
subplot(1,2,2); imshow(cropped2)
or you could use montage:
or since they're the same size, you can just concatenate them and show them as one
DGM on 30 Apr 2021
I don't see anything obviously wrong from the picture. I'd have to be able to run the code and see the particular images to troubleshoot further.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by