Position (X,Y) of cropping window using randomWindow2d
8 views (last 30 days)
I'm using randomWindow2d to crop my image multiple times. However, I need to know the position (X,Y) of the cropping window to use it in further analysis. Is there any possibility to find or get this information? I mean, for example the center position (X,Y) of the cropping window in relation to my orginal image?
The code looks almost the same as on the website:
I = imread("strawberries.jpg");
inputSize = size(I);
scale = [0.2 0.2];
dimensionRatio = [1 1;1 1];
rect = randomWindow2d(inputSize,"Scale",scale,"DimensionRatio",dimensionRatio);
Icrop = imcrop(I,rect);
Image Analyst on 16 Aug 2022
To get the coordinates in the original matrix you'd need to add the xLeft and yTop of the prior crops to those of the current crop. For example if you cropped at x=100 the first time, and now on the cropped image you crop at x=10, that is x=100+10 = 110 of the original image.