File Exchange

## Speckle Size via Autocorrelation

version 1.1 (2.77 KB) by

Outputs the size of speckles in an image that has a **uniform background**.

Updated

This function takes an RGB image as input and gives the FWHM and 1/e^2 radius of Gaussian-assumed speckles in the horizontal and vertical directions in pixel units.
The function is heavily commented for very easy use, and all mathematical steps are explained in the comments. Briefly, the autocovariance of each row (column) is averaged; the resulting plot is fitted to a Gaussian, from which the horizontal (vertical) FWHM and 1/e^2 values are calculated.
In addition, the function outputs the goodness-of-fit statistics for this Gaussian fit. These should always be checked to ensure proper functioning.

Surya Gnyawali

### Surya Gnyawali (view profile)

Hi Joel,

Can you please help me how proceed to play with your Speckle Size via autocorrelation. My question is do I have to make GUI.

Thanks for the help
Surya

Jens Munk Hansen

### Jens Munk Hansen (view profile)

Hey Joel. I looked into your source and found that you have misunderstood how the correlation length can be obtained from the auto-covariance. You are using the FWHM of the fit. The correlation length is the value of the integral itself.

Ariel

### Ariel (view profile)

Hello Joel,

(I just didn't install the Signal Process tool box)

Best,
Ariel

Ariel

### Ariel (view profile)

Hello Joel,

I'm trying to run your function but for some reason i get this error:
% ??? Undefined function or method 'xcov' %for input arguments of type 'double'.

% Error in ==> SpeckleSize at 46
% s=size(xcov(E)); %finds the % size of the autocovariance array

Do you have any idea why do i get this error?

(P.S I'm using MATLAB2010B)

Thank you,
Ariel.

Joel

### Joel (view profile)

The units are just in 'pixels'. If you acquire the image with a camera you would have to find the dimensions of one pixel on your own, perhaps by using a reference (e.g. I know this object is 1.0cm long) or perhaps by some more complicated calculation if you use lenses to focus an image onto a digital camera. Manufacturers' datasheets give pixel sizes for most digital cameras, I believe, which would be one part of that calculation. It is true that without having a pixel-to-distance conversion the program doesn't help much.

Jayanthy Anavai Kandaswami

### Jayanthy Anavai Kandaswami (view profile)

Thanks Joel. The program works fine with my images. What is the units of the calculated speckle size?