Converting 2x2 Matrix into a Polar Function f(r,theta)
shifuxian
Wed, 10/04/2017 - 09:14 pm
Hello, I am pretty new in using Igor Pro and any input from the more experienced users will be very much appreciated. So I have a 2x2 matrix corresponding to an intensity image. The structures of interest are circular and so what I'd like to do is average the intensity over all angles for a given radius. To do this, I am thinking of designating a center and converting the 2x2 matrix into a polar function f(r,theta) and then later on integrate that function over theta so I can get an intensity profile vs radius plot. Does this sound doable in Igor Pro or is there an easier more convenient way to do this? Somebody suggested something about 2D interpolation but I haven't any idea about that yet. Thank you for your inputs!
https://www.igorpro.net/blog/2017/4/4/how-to-average-data-over-an-annul…
October 5, 2017 at 04:45 am - Permalink
Thank you very much for your reply! I find the blog entry very helpful!
October 6, 2017 at 12:37 am - Permalink
Hello, in this particular approach, does the command Interp2d automatically give the f(r,theta) function for my 2x2 matrix? I'm confused as to how I can acquire my f(r,theta). Any help would be very much appreciated. Thank you.
October 9, 2017 at 08:16 am - Permalink
Variable theta=atan2((y-yc),(x-xc))
This means that for a 2D matrix you can write:
Variable rr,theta,xc,yc
Wave dataWave
Variable xx=rr*cos(theta)+xc
Variable yy=rr*sin(theta)+yc
return interp2d(dataWave,xx,yy)
End
I hope this helps,
A.G.
October 9, 2017 at 10:44 am - Permalink
r2polar
andp2rect
.October 9, 2017 at 11:57 am - Permalink
Hello A.G.,
I have made a mistake in my previous posts. I am actually working on a 512x512 matrix, not a 2x2 matrix. What I was trying to say was that I'm dealing with a 2-dimensional wave.
Thank you very much for your inputs! I appreciate them.
October 12, 2017 at 02:49 am - Permalink
Hello again,
I don't know what I'm doing wrong but I keep getting the command error "expected wave name, variable name, or operation" when I run the function procedure. I am using Igor Pro 7.02. Any insights about this? Thank you.
October 12, 2017 at 04:44 pm - Permalink
It is difficult to answer your question without knowing precisely what you are trying to execute, when you are getting this error message and what are the names of the waves involved.
October 13, 2017 at 10:07 am - Permalink
Dear A.G.,
I have solved the previous problem. Thanks!
Here is the nature of the calculation that I want to do. I have intensity profile images and first I want to re-scale (maybe just change the aspect ratio) to force the ring-like structures to be circles (ideally, they should be circular). With this process however, my 2D wave remains unchanged and is still non-square (I think). Then, what I want to do is perform interpolation to get an f(r,theta) and integrate over all theta to get an intensity vs. radius plot, averaged over theta. Do you have any similar routines for such a calculation? Thank you. I am attaching a sample intensity profile image and the corresponding wave.
PS: If the projection on the x-y plane is not a circle, then the limits of integration for r will be in the form of functions. This is a difficulty for me.
October 16, 2017 at 07:44 pm - Permalink