crop 2 images with the same size

4 次查看(过去 30 天)
cyrine tijani
cyrine tijani 2021-4-30
评论: DGM 2021-4-30
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
  3 个评论
Image Analyst
Image Analyst 2021-4-30
Looks like a good answer to me. DGM, can you move it down to the official ANswer section below where you can earn "Reputation Points" for it?
DGM
DGM 2021-4-30
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.

请先登录,再进行评论。

回答(1 个)

DGM
DGM 2021-4-30
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:
montage({cropped1,cropped2})
or since they're the same size, you can just concatenate them and show them as one
imshow(cat(2,cropped1,cropped2))
  3 个评论
cyrine tijani
cyrine tijani 2021-4-30
编辑:cyrine tijani 2021-4-30
hi it worked but i have a little problem the second image appear all black while it shouldn't , here's the code and the interface in the photo bellow if you have a solution please tell me
DGM
DGM 2021-4-30
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by