creating new images using new x,y coordinates from a subplot

3 次查看(过去 30 天)
Hi all,
I have created 4 subplots. I am able to manually zoom into each image and find the x,y coordinates using the pop up bar at the top of the image
My issue is this, I want to zoom in to a particular point, and then re-create the 4 subplots at that zoomed in position.
My code so far is-
figure;
subplot(2,2,1); imshow(EdgeS),title('Sobel');
subplot(2,2,2); imshow(EdgeP),title('Prewitt');
subplot(2,2,3); imshow(EdgeR),title('Roberts');
subplot(2,2,4); imshow(EdgeC),title('Canny');
When I click on the image, it gives me [X,Y] [123 456] (obviously not the real coordinates).
Do i need to click in all four courners, or just in one place?
so where would i add my coordinates in my code?
I hope that makes sense!!
cheers
mike
  2 个评论
Holmbrero
Holmbrero 2020-12-8
I think what you are looking for is imcrop:
Icropped = imcrop(I,rect) crops the image I according to the position and dimensions specified in the crop rectangle rect. The cropped image includes all pixels in the input image that are completely or partially enclosed by the rectangle.
The actual size of the output image does not always correspond exactly with the width and height specified by rect. For example, suppose rect is [20 20 40 30], using the default spatial coordinate system. The upper left corner of the specified rectangle is the center of the pixel with spatial (x,y) coordinates (20,20). The lower right corner of the rectangle is the center of the pixel with spatial (x,y) coordinates (60,50). The resulting output image has size 31-by-41 pixels, not 30-by-40 pixels.

请先登录,再进行评论。

回答(1 个)

mike
mike 2020-12-8
thanks for the repies
so with the xlim which limit would I choose? I have zoomed into the image (all four at the same time as I have linked the axis) but I can pick any point on the image which gives me the xy value. So how would I then decide what the limits are?
many thanks
mike
  2 个评论
Holmbrero
Holmbrero 2020-12-9
编辑:Holmbrero 2020-12-9
xlim(xmin xmax)
ylim(ymin ymax)
So xmin is your starting point on the x-axis and xmax is your end point. The same goes for the y-axis.
/Anders

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Visual Exploration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by