- Img = zeros(128,128,3);
- % Img 蓝色背景
- Img(:,:,1) = 0;
- Img(:,:,2) = 0;
- Img(:,:,3) = 255;
- % 三个彩色高斯噪声(RGB模型)
- g1=zeros(128,128,3);
- g2=zeros(128,128,3);
- g3=zeros(128,128,3);
- %彩色的高斯噪声
- g1(:,:,1) = 2000*randn(128,128); %红色
- g1(:,:,2) = 0;
- g1(:,:,3) = 0;
- g22=randn(128,128);
- g2(:,:,1) = 2000*g22; %???希望是黄色
- g2(:,:,2) = 2000*g22; %怎样设置
- g2(:,:,3) = 0;
- g3(:,:,1) = 0;
- g3(:,:,2) = 2000*randn(128,128); %绿色
- g3(:,:,3) = 0;
- for i=1:128
- for j=1:128
- if (i-64)^2/30^2+(j-20)^2/15^2<1
- Img(i,j,:)=Img(i,j,:)+g1(i,j,:);
- end
- if (i-64)^2/30^2+(j-60)^2/15^2<1
- Img(i,j,:)=Img(i,j,:)+g2(i,j,:);
- end
- if (i-64)^2/30^2+(j-100)^2/15^2<1
- Img(i,j,:)=Img(i,j,:)+g3(i,j,:);
- end
- end
- end
- % 在蓝色背景上添加彩色高斯噪声
- s = uint8(Img);
- imshow(s);
复制代码 |