## Converting 2x2 Matrix into a Polar Function f(r,theta)

shifuxian | October 4, 2017 - 20:14 | ||
---|---|---|---|

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! |

Joined: 2007-08-16

Location: United States

For some related guidelines and approaches take a look at A.G.'s blog post:

https://www.igorpro.net/blog/2017/4/4/how-to-average-data-over-an-annula...

Joined: 2017-10-04

Location: Japan

s.r.chinnwrote:https://www.igorpro.net/blog/2017/4/4/how-to-average-data-over-an-annular-domain

Thank you very much for your reply! I find the blog entry very helpful!

Joined: 2017-10-04

Location: Japan

s.r.chinnwrote:https://www.igorpro.net/blog/2017/4/4/how-to-average-data-over-an-annular-domain

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.

Joined: 2007-06-29

Location: United States

It would be useful if you explained the nature of your 2x2 matrix. If all you have are 4 values there is little point in trying to compute an (r,theta). In general, given a matrix with a defined origin (Xc,Yc) you can perform conversions for any (x,y) in the domain:

This means that for a 2D matrix you can write:

I hope this helps,

A.G.

Joined: 2009-10-07

Location: Germany

Don't forget the builtin functions

`r2polar`

and`p2rect`

.Joined: 2017-10-04

Location: Japan

Igorwrote:This means that for a 2D matrix you can write:

I hope this helps,

A.G.

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.

Joined: 2017-10-04

Location: Japan

Igorwrote:This means that for a 2D matrix you can write:

I hope this helps,

A.G.

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.

Joined: 2007-06-29

Location: United States

shifuxianwrote: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.

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.

Joined: 2017-10-04

Location: Japan

Igorwrote:shifuxianwrote: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.

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.

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.