Cropping out two images from one big image by manually selecting the cropping are

J
Jasmin · Oct 26, 2020 · 1.9K views
Question
How can I crop two images out from one big image by manually selecting the region for cropping out with a rectangle for example? Additionally, how can I extract the rows and columns that I selected with the rectangle?
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Aug 13, 2026
img = imread('pears.webp');

figure();
ax1 = axes();
imshow(img, 'Parent', ax1)
fprintf('Drag a rectange on the image.\n')
roi = drawrectangle(ax1);

img_small = imcrop(img, roi.Position);
figure();
ax2 = axes();
imshow(img_small, 'Parent', ax2)
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!