Create a Simulated Image of Diffraction Limited Spots with Noise

Create images with diffraction-limited spots of varying size and intensity, with noise.
606 Downloads
Aktualisiert 4. Apr 2012

Lizenz anzeigen

Tristan Ursell
March 2012

Create an image with randomly positioned, diffraction-limited spots with full data on actual spot positions and parameters. Useful for testing a spot finding algorithm.

[Iout,Inoise,spot_data]=spotmaker([im_sz],num_spots);
[Iout,Inoise,spot_data]=spotmaker([im_sz],num_spots,'field',value);

im_sz = two column vector specifying the size (rows,columns) of the output image.

num_spots = integer value number of spots to appear in the image.

Iout = full output image, with spots and noise according to all specified parameters.

Inoise = only the noise that appears in Iout.

The output 'spot_data' is a structure array with fields:

spot_data.Xcent(i) = x-center of the Gaussian spot i.
spot_data.Ycent(i) = y-center of the Gaussian spot i.
spot_data.ints(i) = peak height (intensity) of the Gaussian spot i.
spot_data.stds(i) = peak width (STD) of the Gaussian spot i.

length(spot_data.Xcent) = number of spots

The possible field entries are:

'spot_pos' is an optional specification of where the spots should occur in the image. The input should be a two column matrix of X and Y positions. Regardless of the value of 'num_spots', the script will use: num_spots = length(X).

'noise_mu' (-Inf < noise_mu < Inf) is the mean intensity of Gaussian noise in the output image. The default value is 0.

'noise_std' (0 < noise_std < Inf) is the standard deviation of the Gaussian noise in the output image. The default value is 0.

'int_mu' (0 < int_mu < Inf) is the mean spot intensity. The default value is 1.

'int_std' (0 < int_std < Inf) is the standard deviation in spot intensity. The default value is 0.

'wid_mu' (0 < wid_mu < Inf) is the mean width of the spot intensity distribution. The default value is 4.

'wid_std' (0 < wid_std < Inf) is the standard deviation in the widths of the spot intensity distributions. The default value is 0.

'plot' with value 1 will produce an output plot of Iout with the spot centers marked by red circles.

%Simple Example:
[Iout,Inoise,spot_data]=spotmaker([400,500],200,'plot',1);

%More Complex Example:
[Iout,Inoise,spot_data]=spotmaker([400,500],200,'plot',1,'noise_mu',100,...
'noise_std',20,'int_mu',100,'int_std',20,'wid_std',1);

%Specified Position Example:
Xin=linspace(10,400,10)';
Yin=linspace(10,300,10)';

[Iout,Inoise,spot_data]=spotmaker([320,420],200,'spot_pos',[Xin,Yin],'plot',1,...
'noise_mu',100,'noise_std',20,'int_mu',100,'int_std',20,'wid_std',1);

%write to 8 bit output image:
imwrite(uint8(255*mat2gray(Iout)),'spot_test.tif','Compression','none')

Zitieren als

Tristan Ursell (2024). Create a Simulated Image of Diffraction Limited Spots with Noise (https://www.mathworks.com/matlabcentral/fileexchange/36026-create-a-simulated-image-of-diffraction-limited-spots-with-noise), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2012a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0.0