Visualize rectangles chosen by randomCropWindow2d

2 次查看(过去 30 天)
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