Clear Filters
Clear Filters

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

3 views (last 30 days)
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 Comments
Holmbrero
Holmbrero on 8 Dec 2020
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.

Sign in to comment.

Answers (1)

mike
mike on 8 Dec 2020
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 Comments
Holmbrero
Holmbrero on 9 Dec 2020
Edited: Holmbrero on 9 Dec 2020
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

Sign in to comment.

Categories

Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!