필터 지우기
필터 지우기

Visualize rectangles chosen by randomCropWindow2d

조회 수: 2 (최근 30일)
JayJay
JayJay 2021년 1월 27일
댓글: JayJay 2021년 2월 1일
I am trying to vizualize the crop rectangles chosen by the randomCropWindow2d function by overlaying them onto my input image. The function outputs the cropping window as a rectangle object, how can I extract the position from the object and visualize the crop rectangles? Thank you for your help!

채택된 답변

Pratyush Roy
Pratyush Roy 2021년 2월 1일
Hi,
The rectangle object comes with 2 properties, namely, XLimits and YLimits. XLimits captures the lowest and highest value of position along x-axis in the cropped image, whereas YLimits captures the lowest and highest values along y-axis in the cropped image. The snippet below might be helpful to obtain the position from the window object win1:
xmin = win1.XLimits(1);
xmax = win1.XLimits(2);
ymin = win1.YLimits(1);
ymax = win1.YLimits(2);
To visualise the cropped image, one can use the imcrop function to crop out the rectangle and then use imshow to visualise the rectangle. The following code snippet demonstrates how to visualise the rectangle:
B = imcrop(A,win1); % win1 here referes to the rectangular window object and A is the array obtained after reading the image
imshow(B)
One can refer to the following link for further information:
Hope this helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by