To problem is a quite simple one I have a matrix say n x m and every element represents a z-value. What I want to do is transform the incices n and m into polar cooordinates based on the image center.
The center of the matrix is denoted as (n0, m0) and the last pixel by (nMax, mMax). So I used two for loops one cycling n one cycling m and then use cart2pol to transform the coordinates and save them to an array.
polarCoordinates = ;
[theta, rho, z] = cart2pol(n-n0, m-m0, image(n,m));
polarCoordinates = [polarCoordinates; theta, rho, z];
This approach works but given the two for loops it is very slow. So I am looking for an elegant solution to speed up the process.
I know cart2pol can handle arrays of x, y, z values for transformation, e.g. n,m,image(n,m). To form those arrays I'd need to cycle tha matrix with the for loops as well or maybe not? Any ideas?
Thanks for the help!