The two corners of the random rectangle are hiden in the formula and the position of them is visible in command window when you remove ";" after the formula. Just in case if some wants to find it.
Position (X,Y) of cropping window using randomWindow2d
1 次查看(过去 30 天)
显示 更早的评论
Hi,
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");
imshow(I)
inputSize = size(I);
scale = [0.2 0.2];
dimensionRatio = [1 1;1 1];
rect = randomWindow2d(inputSize,"Scale",scale,"DimensionRatio",dimensionRatio);
Icrop = imcrop(I,rect);
imshow(Icrop);
imwrite(Icrop,'strawb_crop.jpg');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1097720/image.png)
回答(1 个)
Image Analyst
2022-8-16
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!