Borrar filtros
Borrar filtros

Show img in coordinate system and perform transformations

1 visualización (últimos 30 días)
Farhan
Farhan el 9 de Dic. de 2023
Comentada: Farhan el 10 de Dic. de 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 comentarios
Catalytic
Catalytic el 10 de Dic. de 2023
You asked essentially the same question and got essentially the same answers in this earlier post. Why did you abandon it?
Farhan
Farhan el 10 de Dic. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 9 de Dic. de 2023
Editada: Matt J el 10 de Dic. de 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 comentarios
Farhan
Farhan el 10 de Dic. de 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 el 10 de Dic. de 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.

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 9 de Dic. de 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.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by