Cropping out two images from one big image by manually selecting the cropping are
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
windmill
am 25 Okt. 2020
Kommentiert: Ameer Hamza
am 29 Okt. 2020
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?
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 25 Okt. 2020
Try this code
img = imread('pears.png');
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)
4 Kommentare
Ameer Hamza
am 29 Okt. 2020
Try this code
image = imread('pears.png');
image2 = rgb2gray(image);
figure();
ax1 = axes();
imshow(image2, 'Parent', ax1)
fprintf('Draw the ROI on the image using the rectangle.\n')
roi = drawrectangle(ax1);
roiPos=roi.Position;
cropped_image = imcrop(image2, roi.Position);
figure();
ax2 = axes();
imshow(cropped_image, 'Parent', ax2)
Weitere Antworten (1)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!