Create a Simulated Image of Diffraction Limited Spots with Noise

版本 1.0.0.0 (2.9 KB) 作者: Tristan Ursell
Create images with diffraction-limited spots of varying size and intensity, with noise.
606.0 次下载
更新时间 2012/4/4

查看许可证

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')

引用格式

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. 检索来源 .

MATLAB 版本兼容性
创建方式 R2012a
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0