Show img in coordinate system and perform transformations

1 Ansicht (letzte 30 Tage)
Farhan
Farhan am 9 Dez. 2023
Kommentiert: Farhan am 10 Dez. 2023
I want to show my image in xy-coordinate system, Now I have img and I can read it without any problem
I = imread('img.png');
size(I); % 16 x 15
imshow(I);
Now the img shows like this,
Now I wanted it to be shown like a graph with proper x,y coordinates.
For example the size of img is 16x15 and corners of the img by default should be as
Bottom Left: (0,0)
Bottom Right: (16, 0)
Top Left: (0, 15)
Top Right: (16, 15)
Now, comes the real part. img is displayed in coordinate system with these points.
Now I want to perform transformations, I will try to explain it in detail with example
For example I am given a scenerio
Apply Shear of factor 2 in y direction. Now first we find the Standard matrix and then get new coordinates
The 2nd is the Standard matrix while thrd is the unit vector (img in our case) and fourth is the transformed vector.
I want to do this with the img, using Standard matrix getting new coordinates and displaying img accordingly. I can show it mathematically in detail.
Now the standard matrix will be
T = [1 0
2 1] % from the above img
Now new coordinates would be
Bottom Left = T * [0; 0] = [0; 0]
Bottom Right: (16, 0) = T * [16; 0] = [16; 32]
Top Left: (0, 15) = T * [0; 15] = [0; 15]
Top Right: (16, 15) = T * [16; 15] = [16; 47]
Now, I have the new coordinates, I want the img to be displayed according to the new coordinates. This is the end goal I want to acheive. I would have to apply different Standard matrixes at different ocations, so do not want the solution to work only for shear factor.
  2 Kommentare
Catalytic
Catalytic am 10 Dez. 2023
You asked essentially the same question and got essentially the same answers in this earlier post. Why did you abandon it?
Farhan
Farhan am 10 Dez. 2023
I tried messing with that but could not get what I wanted, I thought I might have done question wrong. So decided to make it more clear.Now I have understood what to do. Thanks.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt J
Matt J am 9 Dez. 2023
Bearbeitet: Matt J am 10 Dez. 2023
I=flipud(imread('peppers.png'));
T = [1 0
2 1]; T(3,3)=1;
[Iw,R]=imwarp(I, affine2d(T'));
h=imshow(Iw);
axis on xy;
set(h,'XData',R.XWorldLimits,'YData',R.YWorldLimits);
set(gca,'XLim',R.XWorldLimits,'YLim',R.YWorldLimits);
  4 Kommentare
Farhan
Farhan am 10 Dez. 2023
The axis is set on after the img is shown, I think this is causing the wrong xy position in reflection case, because the img should be below the x-axis line. Similar problem in reflection against y-axis
Also, can you explain this a bit so I can try it my self too
Matt J
Matt J am 10 Dez. 2023
The axis is set on after the img is shown, I think this is causing the wrong xy position in reflection case
I fixed it.
Also, can you explain this a bit so I can try it my self too
I would need specific questions. imwarp does all the work, so you should definitely read that doc page thoroughly.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 9 Dez. 2023
"I want to show my image in xy-coordinate system" <== Did you try calling axis xy?
axis xy
Call it after you call imshow.

Kategorien

Mehr zu Image Preview and Device Configuration finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by