Imagelineprofile with /Rad flag Question

Hi,

In the documentation the example below is given

ImagelineProfile/RAD={50,50,24.5,0.5,0.001}/IRAD=100 srcWave=ddd 

Xcenter = 50

Ycenter = 50

Radius =24.5

Width =0.5 (I am assuming it is +/-)

DeltaAngle = 0.001 (in radians)

/IRAD=100

What does 100 mean here?  If the circle is 2Pi radians and there are 0.001 radians per step there are 2000Pi points.  100 is not that number?  What does it refer to?

 

Andy

Following the example in the documentation.

Make/O/N=(100,100) ddd=sqrt((x-50)^2+(y-50)^2)       
ImagelineProfile/RAD={50,50,24.5,0.5,0.001}/IRAD=100 srcWave=ddd
Print V_integral

It returns a value of 

3770.881728281965

along with 5 waves

W_ImageLineProfie 6283 points all NaNs

W_LineProfileDisplacement 6283 points from 0 to 153.889  to last point before circle is closed (2*pi*24.5 = 153.938)

W_LineProfileX 6283 points with X position

W_LineProfileY 6283 points with Y position

W_radIntegral 6283 points of value ~ 0.600184 except last point = 0

If I remove the /IRAD flag then imagelineprofile has values and zero NaNs and no W-radintegral wave is created, is this the intended behavior?

I also notice that /IRAD number needs to be even.

If I change the delta in the /RAD flag to 0.1 radian

ImagelineProfile/RAD={35,50,24.5,0.5,0.1}/IRAD=1000 srcWave=ddd

Then all but the w_radintegral are 126 points and the w_radintegral is 63 points.

Do the two radian values need to align?

Andy

While I am on roll.

What is the intended behavior if the profile goes outside the limits of the underlying matrix?

Example I have set the center and the radius to sample outside the underlying image.

ImagelineProfile/RAD={10,10,24.5,0.5,0.001}/IRAD=100 srcWave=ddd

The X and Y line profile correctly go into the negative.  With the /IRAD flag the W_ImageLineProfile is all NaNs, while the W_RadIntegral has zero for points that lie outside the image. The function returns a V_Integral value of 2346 instead of the expected NaN.

Without the /IRAD flag the W_IamgeLineProfile shows NaNs where for regions outside the image.

Andy

Hi Andy,

When you have so many questions you are better off calling us.

A.G.

Hi,

Had a nice chat with AG and answered some questions.

1. /IRAD flag is the number of samples at each angular position in the radial direction between the lower radial limit and upper radial limit.  Important to understand the DeltaAngle describes the circumferential angle, the /IRAD is the number of samples in the radial direction.

2. If you do a radial profile that goes outside the image , the W_imageLineProfile will have Nans where you exceed the image.

   /IRAD V_integral will have 0 (zero) for the points outside the image and will not contribute to the integral value reported, and will return the integral of the valid points.

Different approaches and use them as desired.

The /IRAD number must be even.

When /IRAD is used the W_ImageLineProfile wave is not computed and is all NaNs.

Andy

 

For the benefit of others who may have similar questions:

Here are two functions that help illustrate the situation:

Function example1()
    Make/O/N=(100,100) ddd=sqrt((x-50)^2+(y-50)^2)
    newimage ddd
    make/o/n=360 xxx,yyy,xmin,ymin,xmax,ymax
    variable da=2*pi/359
    xmin=50+24*cos(da*p)
    xmax=50+25*cos(da*p)
    ymin=50+24*sin(da*p)
    ymax=50+25*sin(da*p)
    xxx=50+24.5*cos(da*p)
    yyy=50+24.5*sin(da*p)
    appendtograph/T yyy vs xxx
    appendtograph/t ymin vs xmin
    appendtograph/t ymax vs xmax
    ModifyGraph rgb(ymin)=(0,0,65535),rgb(ymax)=(65535,65535,0)
    ImagelineProfile/RAD={50,50,24.5,0.5,0.001}/IRAD=100 srcWave=ddd
    Print V_integral
End

Function example2(wave ddd)
    newimage ddd
    make/o/n=360 xxx2,yyy2
    variable da=2*pi/359
    xxx2=50+55*cos(da*p)
    yyy2=50+55*sin(da*p)
    appendtograph/T yyy2 vs xxx2
    ImagelineProfile/RAD={50,50,40,0.5,0.001}/IRAD=100 srcWave=ddd
    Print V_integral
End

The first function shows image data and 3 concentric rings (blue, red, and yellow).  The /IRAD=100 flag means that for every point on the red ring the intensity is evaluated at 100 radial locations.  Here the tradeoff is performance vs accuracy and depends on the extent of variation of the data in the radial direction.

Example2() illustrates a situation where the path extends in part outside the range of the data.  Here one could have a valid expectation that the operation would return a NaN (if you want to count points outside the data), but what if you want to know the integrated intensity for points inside the image?  I suppose we could suggest to embed the image in a larger image where all the pixels are set to zero or return the integral for values inside the image as is implemented. 

Note:

1.  When performing the radial calculation the path is generated internally (from the parameters in the /Rad flag) but the profile wave is not populated as it is essentially equivalent to the data in W_radIntegral.

2.  The last value in W_radIntegral corresponds to the wrap-around point and is therefore set to zero (a non-zero value would change the integral).