Code covered by the BSD License

### Highlights from Speckle Size via Autocorrelation

4.0
4.0 | 1 rating Rate this file 18 Downloads (last 30 days) File Size: 2.77 KB File ID: #25046 Version: 1.1

# Speckle Size via Autocorrelation

by

### Joel (view profile)

16 Aug 2009 (Updated )

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

File Information
Description

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.

Required Products Curve Fitting Toolbox
Image Processing Toolbox
Signal Processing Toolbox
MATLAB release MATLAB 7.8 (R2009a)
21 May 2012 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

Comment only
09 Sep 2011 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.

Comment only
06 Jun 2011 Ariel

### Ariel (view profile)

Hello Joel,

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

Best,
Ariel

Comment only
06 Jun 2011 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.

Comment only
07 Jul 2010 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.

Comment only
26 Mar 2010 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?