Crop Images With Specified Values From Each Direction
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Bugrahan Guner
il 21 Ago 2023
Commentato: Walter Roberson
il 21 Ago 2023
I want to crop a series of '.bmp' images. Is there a way to crop images by putting 4 variables indicating how many pixels you want to cut from each side (from each direction; top, bottom, left, and right) of the image? I want the users to change the amount they want to cut from each of the four sides and basically shrink down the image accordingly. Thanks for the help in advance.
2 Commenti
Dyuman Joshi
il 21 Ago 2023
Modificato: Dyuman Joshi
il 21 Ago 2023
imcrop could be helpful if you have the Image Processing Toolbox.
Walter Roberson
il 21 Ago 2023
Notice this in the imcrop() documentation:
The actual size of the output image does not always correspond exactly with the width
and height specified by rect. For example, suppose rect is [20 20 40 30], using the
default spatial coordinate system. The upper left corner of the specified rectangle
is the center of the pixel with spatial (x,y) coordinates (20,20). The lower right
corner of the rectangle is the center of the pixel with spatial (x,y) coordinates
(60,50). The resulting output image has size 31-by-41 pixels, not 30-by-40 pixels.
Risposta accettata
Walter Roberson
il 21 Ago 2023
newImage = OriginalImage(1+TopRowsToSkip:end-BottomRowsToSkip, 1+LeftColumnsToSkip:end-RightColumnsToSkip, :);
where you should probably let all the values such as TopRowsToSkip start at 0 (indicating nothing to be skipped)
I would not recommend using imcrop() for this purpose.
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!