필터 지우기
필터 지우기

crop image with fixed x/y ratio

조회 수: 1 (최근 30일)
safa
safa 2013년 5월 19일
I want to crop image using following code. but i want to user only can select the crop area with a predefined x/y ratio.for example if x=2,y=2 ,then user can only use mouse to select an area with (x/y)=1 ratio.
I = imread('image.jpg');
[rows columns numberOfColorBands] = size(I);
I2 = imcrop(I);
imshow(I), figure, imshow(I2)

답변 (1개)

Image Analyst
Image Analyst 2013년 5월 19일
You'd have to tie into the mouse move event and draw a box based on the starting point, and some other corner, based on the current mouse location but with the aspect ratio forced to be what you want. Or else just call rbbox() or imrect() and let them draw whatever and fix it up after they finish the box.

Community Treasure Hunt

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

Start Hunting!

Translated by