Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 在不添加噪声的情况下生成高斯图像_Matlab_Image Processing - Fatal编程技术网

Matlab 在不添加噪声的情况下生成高斯图像

Matlab 在不添加噪声的情况下生成高斯图像,matlab,image-processing,Matlab,Image Processing,我想用Matlab生成一个高斯图像。它有三个圆作为三个类。每个圆中的强度将遵循高斯分布。因此,图像的直方图将乘上高斯分布作为一个整体。然而,我使用了一个无噪声的图像,并将其与高斯噪声一起添加,以使其具有多重高斯分布,这是非常有噪声的。在这个问题上,我正在寻找一种生成合成高斯图像的方法,这与我以前添加噪声的方法不同。感谢阅读下面的代码通过生成单调递减的方形图案图像,在3个高斯混合后创建一个图像,如果需要,可以很容易地外极化到更多的高斯 它的工作方式是 根据所需的分布生成随机数 我说的是数字 从图像

我想用Matlab生成一个高斯图像。它有三个圆作为三个类。每个圆中的强度将遵循高斯分布。因此,图像的直方图将乘上高斯分布作为一个整体。然而,我使用了一个无噪声的图像,并将其与高斯噪声一起添加,以使其具有多重高斯分布,这是非常有噪声的。在这个问题上,我正在寻找一种生成合成高斯图像的方法,这与我以前添加噪声的方法不同。感谢阅读

下面的代码通过生成单调递减的方形图案图像,在3个高斯混合后创建一个图像,如果需要,可以很容易地外极化到更多的高斯

它的工作方式是

根据所需的分布生成随机数 我说的是数字 从图像中心向外旋转,并逐像素插入排序值 代码:

输出:


请不要犹豫,向我询问有关代码的任何问题,但希望它是不言自明的。

这很难做到,主要是因为图像是方形的,而您需要圆形。如果图像是圆形的,这很容易,但是要填充其他图像中黑色部分的角是很难的,或者说不是很难,因为你需要完全控制每种颜色的像素量。@AnderBiguri:形状并不重要。主要的问题是如何生成一幅图像,其中每一类的强度后面是高斯分布。形状至关重要。正如我在你的另一个问题中所说的,有无数种可能的形状!不管怎样,你能给出你想要的3个高斯数的平均值和标准差吗?如果你分享这些信息,我可能会试图解决这个问题;谢谢你的代码。很抱歉我的回复晚了。如果我想再创建一个最小半径的正方形,我怎样才能旋转参数?你说的再创建一个正方形是什么意思?直方图中的另一个高斯分布?我认为这很明显,如果你读代码!我真的不知道如何让它变得更明显@用户8430
rows=256; columns=256;
grayImage=zeros(rows,columns);

% We will work with doubles in the range of 0-255, and then we will
% discretize, for the shake of dealing properly with random numbers

%define gaussians
mean1=30;   std1=10;
mean2=100;  std2=10;
mean3=130;  std3=5;

% how many points on each of them?? 
% equal:
n=ceil(rows*columns/3);
% Random samples I tested to make it look as your image
n1=ceil(rows*columns/5);
n2=ceil(2/5*rows*columns);
n3=ceil(2/5*rows*columns);
%generate random numbers
rnd1=normrnd(mean1,std1,n1,1);
rnd2=normrnd(mean2,std2,n2,1);
rnd3=normrnd(mean3,std3,n3,1);

%now the hard part.


rnd=[rnd1;rnd2;rnd3];
% Does this looks like what you want? Tune above parameters if it doesnt.
% histogram(rnd)

% Sort the data
rnd=sort(rnd,'descend');


% Here comes the tricky part: filling the image. I chose square shaped, and
% I fill it in a spiral, starting from the center
% web('https://stackoverflow.com/questions/398299/looping-in-a-spiral')
x= 0;
y= 0;
dx = 0;
dy = -1;
next=1;
for ii= 1:rows*columns
    if (-rows/2 < x <= rows/2) && (-columns/2 < y <= columns/2)
        grayImage(x+columns/2,y+rows/2)=rnd(next);
        next=next+1;
    end
    if x == y || (x < 0 && x == -y) || (x > 0 && x == 1-y)
        auxdx=dx;
        dx=-dy; 
        dy =auxdx;
    end
    x=x+dx;
    y=y+dy;
end


% 
subplot(121);imshow(uint8(grayImage)); title('Syntetic image');
subplot(122);imhist(uint8(grayImage)); title('Histogram');