create grid in polar coordinates

25 visualizaciones (últimos 30 días)
Charlotte Piette
Charlotte Piette el 8 de En. de 2023
Comentada: Walter Roberson el 9 de En. de 2023
I have obtained an image in cartesian coordinates that looks like this, with a semi-circular shape. I would like to deduce the polar coordinates of each point in which the reference points are the following:
  • for the radius, the zero is at the center left of the image (and the maximal value would be 150 at the top left or center right)
  • for the angle, the zero would be at the bottom left of the image
So if I start to create two grid matrices for (rho,theta) coordinates that would map my initial matrix, it would look like this (of course I would want the same number of elements between the three matrices, here is just a simplified version with smaller size) :
I don't want how to fill the interrogation marks... Which functions should I use? I tried meshgrid but it could not make it work...
Thank you for your help!
rho_matrice=[150 ? ? ? ?;
100 ? ? ? ?;
50 ? ? ? ?;
0 50 10 150;
50 ? ? ? ?;
100 ? ? ? ?
150 ? ? ? ?];
theta_matrice=[pi ? ? ?;
5pi/6 ? ? ?
2pi/3 ? ? ?;
pi ? ? ?
2pi/6 ? ? ?
1pi/6n ? ? ?
0 pi/6 2*pi/6 pi]
  1 comentario
Walter Roberson
Walter Roberson el 9 de En. de 2023
I wonder if the radon transform would be of use to you?

Iniciar sesión para comentar.

Respuestas (1)

Voss
Voss el 8 de En. de 2023
After constructing your x- and y-coordinates with meshgrid, you can use cart2pol to convert them to polar coordinates.
x = 0:50:150;
y = 150:-50:-150;
[x_matrice,y_matrice] = meshgrid(x,y)
x_matrice = 7×4
0 50 100 150 0 50 100 150 0 50 100 150 0 50 100 150 0 50 100 150 0 50 100 150 0 50 100 150
y_matrice = 7×4
150 150 150 150 100 100 100 100 50 50 50 50 0 0 0 0 -50 -50 -50 -50 -100 -100 -100 -100 -150 -150 -150 -150
[theta_matrice,rho_matrice] = cart2pol(x_matrice,y_matrice)
theta_matrice = 7×4
1.5708 1.2490 0.9828 0.7854 1.5708 1.1071 0.7854 0.5880 1.5708 0.7854 0.4636 0.3218 0 0 0 0 -1.5708 -0.7854 -0.4636 -0.3218 -1.5708 -1.1071 -0.7854 -0.5880 -1.5708 -1.2490 -0.9828 -0.7854
rho_matrice = 7×4
150.0000 158.1139 180.2776 212.1320 100.0000 111.8034 141.4214 180.2776 50.0000 70.7107 111.8034 158.1139 0 50.0000 100.0000 150.0000 50.0000 70.7107 111.8034 158.1139 100.0000 111.8034 141.4214 180.2776 150.0000 158.1139 180.2776 212.1320
Note cart2pol uses the standard convention that theta is zero in the center-right of the image (corresponding to x = 150, y = 0, the positive x-axis). Since you want theta to be zero in the bottom left of the image (corresponding to x = 0, y = -150, the negative y-axis), you can add pi/2 to theta_matrice to make it conform to your convention.
theta_matrice = theta_matrice+pi/2
theta_matrice = 7×4
3.1416 2.8198 2.5536 2.3562 3.1416 2.6779 2.3562 2.1588 3.1416 2.3562 2.0344 1.8925 1.5708 1.5708 1.5708 1.5708 0 0.7854 1.1071 1.2490 0 0.4636 0.7854 0.9828 0 0.3218 0.5880 0.7854
  2 comentarios
Charlotte Piette
Charlotte Piette el 9 de En. de 2023
Thank you very much for your help!
Voss
Voss el 9 de En. de 2023
You're welcome! Any questions, let me know. Otherwise, please "Accept This Answer". Thanks!

Iniciar sesión para comentar.

Categorías

Más información sobre Cartesian Coordinate System Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by