Finding the accurate radius of a particle beam from an image

Hi all, I have a tif image of a particle beam. My goal is to find the exact/most accurate radius of the beam with precision from the image. The image is pretty clear, still I did some background subtraction, and then applied edge detection with one of the Igor’s built-in edge detection techniques. Next, I was trying to fit a circle to the edges of the beam and now am thinking to take the radius of the fitted circle as the radius of the beam.  What would be the best appropriate approach to find the exact radius of the beam in this case? Also, I am a bit confused, there are many Igor's edge detection techniques such as Canny, Kirsch, Sobel etc. and different techniques produce different edges. Which technique is the best to follow here? Is there any built in function in Igor Pro to fit a circle to an image? Notice that I want to find the MOST accurate radius with uncertainty as much accurate as it is possible.  Since the forum doesn't allow to attach tif image, I am attaching the experiment containing the image for your convenience.  Thanks in advance.  A   Experiment.pxp

Before finding an accurate radius, you would first need to define what you want as 'radius'. The 'signal' rises across a few pixels to an average but not perfectly stable ~249. So what do you define as the radius? Where the value has decreased sufficiently? Where the value reaches exactly half? Where the plateau begins to decline? Each question will give you a different answer. Furthermore, it seems that the spot is almost but not exactly circular. So at best, you get an average radius. Is this what you want? I took a simple approach for now: I extracted a vertical and horizontal slice from the spot center and then used FindLevels to extract the positions at half the height, then calculated the distance between them:

FindLevels/Q profile_H, 249/2
print (W_FindLevels[1]-W_FindLevels[0])/2
  15.6519
FindLevels/Q profile_V, 249/2
print (W_FindLevels[1]-W_FindLevels[0])/2
  15.7455

Is this what you want? In any case, I assume your error will be ~ -0.2 px or larger no matter the technique simply because of the limited image resolution.

By radius, I meant where the beam intensity drops drastically reduced to zero (I know it's a bit confusing to define the edge).  

Thanks for your response.

I was looking for some other technique that will define the zero intensity edge and fit a circle to that edge, giving the radius of the fitted circle as the radius of the image.

 

A

I think you still haven't found a good criterion for your radius. You write 'drops drastically reduced to zero', but your data drops drastically and then reduces to zero at completely different positions, which again gives you different answers. You need something stricter, like 'the position where the signal has dropped by 95%' or 'the position where there is exactly no signal anymore', or as stated before 'the position where the signal has dropped by 1/2'. Below I have defined a fit function using tanh(), which can describe the smooth decrease in signal at the edges. The radius is reported plus two times the width of the tanh(), which should give you the position where the signal has decreased by ~95%. Note that the function only has one radius parameter and thus assumes that the spot is circular.

Function SpotCircle(w,x,y) : FitFunc
    Wave w
    Variable x
    Variable y

    //CurveFitDialog/ These comments were created by the Curve Fitting dialog. Altering them will
    //CurveFitDialog/ make the function less convenient to work with in the Curve Fitting dialog.
    //CurveFitDialog/ Equation:
    //CurveFitDialog/ f(x,y) = scale/2*(1-tanh((sqrt((x-x0)^2+(y-y0)^2)-(r-2*smth))/smth))
    //CurveFitDialog/ End of Equation
    //CurveFitDialog/ Independent Variables 2
    //CurveFitDialog/ x
    //CurveFitDialog/ y
    //CurveFitDialog/ Coefficients 5
    //CurveFitDialog/ w[0] = scale
    //CurveFitDialog/ w[1] = x0
    //CurveFitDialog/ w[2] = y0
    //CurveFitDialog/ w[3] = smth
    //CurveFitDialog/ w[4] = r

    return w[0]/2*(1-tanh((sqrt((x-w[1])^2+(y-w[2])^2)-(w[4]-2*w[3]))/w[3]))
End

With this I get:

Make/D/N=5/O W_coef
•W_coef[0] = {250,50,50,1,16}
FuncFitMD SpotCircle W_coef 'orgnlCroppedBeamImgwv.tif' /D
  Fit converged properly
  'fit_orgnlCroppedBeamImgwv.tif'= SpotCircle(W_coef,x,y)
  W_coef={245.85,50.051,50.571,1.0952,17.94}
  V_chisq= 18782.7;V_npnts= 10201;V_numNaNs= 0;V_numINFs= 0;
  V_startRow= 0;V_endRow= 100;V_startCol= 0;V_endCol= 100;
  W_sigma={0.0555,0.00142,0.00142,0.00185,0.00371}
  Coefficient values ± one standard deviation
    scale   = 245.85 ± 0.0555
    x0      = 50.051 ± 0.00142
    y0      = 50.571 ± 0.00142
    smth    = 1.0952 ± 0.00185
    r       = 17.94 ± 0.00371

 

I imported your image into Image Tools + Radial Profiler to work with it. I used thresholding to create a filled region. I found that the edge of the filled region is pixelated. A 101 x 101 image size is not much in resolution compared to the beam radius. I continued with the radial profiler to fit the smallest circle. The results are comparable to @chozo's answer -- 17 pixels. The snapshot is attached below.

My first thought is, when you want to improve the precision on the beam radius, either increase the pixel density in the image or increase the size of the beam in filling the 101 x 101 frame. With what you have, I might not quote a radius with a resolution precision lower than ± 0.5 pixel. My second thought is, you may likely do just as well as both @chozo and I have done with our sophisticated approaches by doing something relatively easy. Draw a line profile over the image. Locate a horizontal line going through the center. Take the profile width at a cutoff level that you decide. Repeat with a vertical line profile. You have two radii, rh and rv. Average them. Here again, I might suggest an uncertainty of ± 0.5 pixel as the minimum, both due to the pixelation at the edge and the general sense of reading uncertainties on graphs.

Hope this helps.

EDIT: After further thought, I realized the basic measurement uncertainty for line profiles will be half the measurement division, becoming ± 0.5 pixel not ± 1 pixel. For a radius of 17.0 pixels, this is a relative uncertainty of 0.5/17.0 ~ 3%. I'd call this level a "well calibrated experiment". You can improve the relative precision in one case by increasing the pixel number density -- keeping the beam size the same but imaging in a 1001 x 1001 pixel image for a beam radius of 170 pixels will reduce the relative precision uncertainty to ± 0.3%. Alternatively, you can increase the spot size within the same pixel density -- making the radius 68 pixels rather than 17 pixels by magnifying the spot size by a factor of four will reduce the relative precision uncertainty to 0.75%. Finally, the method used by @chozo also decreases the precision uncertainty (significantly), primarily because it averages over N points around the beam perimeter to find a best fit radius.