MATLAB加Beta分布噪声图像和加Beta分布噪声图像直方图

286 篇文章 32 订阅
236 篇文章 15 订阅

在这里插入图片描述
clc,clear,close all
warning off
feature jit off
im = imread(‘coloredChips.png’);
Z1 = imnoise_Beta(size(im,1),size(im,2),5,2);
Z1 = im2uint8(Z1); % 类型转换
figure(‘color’,[1,1,1]),
im(:,:,1) = im(:,:,1) + Z1; % R
im(:,:,2) = im(:,:,2) + Z1; % G
im(:,:,3) = im(:,:,3) + Z1; % B
subplot(121); imshow(im);title(‘加Beta分布噪声图像’)
subplot(122); imhist(Z1); title(‘加Beta分布噪声图像直方图’)
在这里插入图片描述

clc,clear,close all
warning off
feature jit off
D0 = 50; % 阻止的频率点与频域中心的距离
W = 3; % 带宽
im = imread(‘coloredChips.png’); % 原图像
R = imnoise(im(:,:,1),‘gaussian’,0,0.01); % R + 白噪声
G = imnoise(im(:,:,2),‘gaussian’,0,0.01); % G + 白噪声
B = imnoise(im(:,:,3),‘gaussian’,0,0.01); % B + 白噪声
im = cat(3,R,G,B); % 原图像 + 白噪声
H = freqfilter_ideal(2size(R,1),2size(R,2),D0,W);
R1 = fftfilt2(R,H);
G1 = fftfilt2(G,H);
B1 = fftfilt2(B,H);
im1 = cat(3,R1,G1,B1);
im1 = uint8(im1);
figure(‘color’,[1,1,1])
subplot(121),imshow(im,[]); title(‘原始图像’)
subplot(122),imshow(im1,[]); title(‘带阻滤波图像’)
在这里插入图片描述
clc,clear,close all
warning off
feature jit off
D0 = 64; % 阻止的频率点与频域中心的距离
im = imread(‘coloredChips.png’); % 原图像
R = imnoise(im(:,:,1),‘gaussian’,0,0.01); % R + 白噪声
G = imnoise(im(:,:,2),‘gaussian’,0,0.01); % G + 白噪声
B = imnoise(im(:,:,3),‘gaussian’,0,0.01); % B + 白噪声
im = cat(3,R,G,B); % 原图像 + 白噪声
H = freqfilter_ideal_Hp(2size(R,1),2size(R,2),D0); % 理想高通滤波器
R1 = fftfilt2(R,H);
G1 = fftfilt2(G,H);
B1 = fftfilt2(B,H);
im1 = cat(3,R1,G1,B1);
im1 = uint8(im1);
figure(‘color’,[1,1,1])
subplot(121),imshow(im,[]); title(‘原始图像’)
subplot(122),imshow(im1,[]); title(‘理想高通滤波图像’);

在这里插入图片描述
clc,clear,close all
warning off
feature jit off
D0 = 2; % 阻止的频率点与频域中心的距离
im = imread(‘coloredChips.png’); % 原图像
R = imnoise(im(:,:,1),‘gaussian’,0,0.01); % R + 白噪声
G = imnoise(im(:,:,2),‘gaussian’,0,0.01); % G + 白噪声
B = imnoise(im(:,:,3),‘gaussian’,0,0.01); % B + 白噪声
im = cat(3,R,G,B); % 原图像 + 白噪声
R1 = freqfilter_ideal_lp(R,D0); % 理想低通滤波器
G1 = freqfilter_ideal_lp(G,D0); % 理想低通滤波器
B1 = freqfilter_ideal_lp(B,D0); % 理想低通滤波器
im1 = cat(3,R1,G1,B1);
figure(‘color’,[1,1,1])
subplot(121),imshow(im,[]); title(‘原始图像’)
subplot(122),imshow(im1,[]); title(‘理想低通滤波图像’);
在这里插入图片描述
clc,clear,close all % 清理命令区、清理工作区、关闭显示图形
warning off % 消除警告
feature jit off % 加速代码运行
D0 = 4; % 阻止的频率点与频域中心的距离
u0 = 50;
v0 = 3;
im = imread(‘coloredChips.png’); % 原图像
R = imnoise(im(:,:,1),‘gaussian’,0,0.01); % R + 白噪声
G = imnoise(im(:,:,2),‘gaussian’,0,0.01); % G + 白噪声
B = imnoise(im(:,:,3),‘gaussian’,0,0.01); % B + 白噪声
im = cat(3,R,G,B); % 原图像 + 白噪声
H = freqfilter_ideal_sink(2size(R,1),2size(R,2),u0,v0,D0); % 理想陷波滤波器
R1 = fftfilt2(R,H); % 频域滤波
G1 = fftfilt2(G,H); % 频域滤波
B1 = fftfilt2(B,H); % 频域滤波
im1 = cat(3,R1,G1,B1);
im1 = uint8(im1);
figure(‘color’,[1,1,1])
subplot(121),imshow(im,[]); title(‘原始图像’)
subplot(122),imshow(im1,[]); title(‘理想陷波滤波图像’);
在这里插入图片描述
clc,clear,close all
warning off
feature jit off
D0 = 20; % 阻止的频率点与频域中心的距离
W = 20; % 带宽
x = 0:.5:80;
y = 0:.5:80;
[X,Y] = meshgrid(x,y);
for i=1:size(X,1)
for j=1:size(X,2)
if sqrt( (X(i,j)-40).^2 + (Y(i,j) -40).^2) <D0-W/2
Z(i,j)=1;
elseif sqrt( (X(i,j)-40).^2 + (Y(i,j) -40).^2)<D0+W/2 …
&& sqrt( (X(i,j)-40).^2 + (Y(i,j) -40).^2)>=D0-W/2
Z(i,j)=0;
elseif sqrt( (X(i,j)-40).^2 + (Y(i,j) -40).^2)>D0+W/2
Z(i,j)=1;
end
end
end
figure(‘color’,[1,1,1])
mesh(X,Y,Z)
在这里插入图片描述
clc,clear,close all
warning off
feature jit off
D0 = 30; % 阻止的频率点与频域中心的距离
x = 0:.5:80;
y = 0:.5:80;
[X,Y] = meshgrid(x,y);
for i=1:size(X,1)
for j=1:size(X,2)
if sqrt( (X(i,j)-40).^2 + (Y(i,j) -40).^2) <D0
Z(i,j)=1;
elseif sqrt( (X(i,j)-40).^2 + (Y(i,j) -40).^2)>=D0
Z(i,j)=0;
end
end
end
figure(‘color’,[1,1,1])
mesh(X,Y,Z)
在这里插入图片描述
clc,clear,close all
warning off
feature jit off
D0 = 30; % 阻止的频率点与频域中心的距离
x = 0:.5:80;
y = 0:.5:80;
[X,Y] = meshgrid(x,y);
for i=1:size(X,1)
for j=1:size(X,2)
if sqrt( (X(i,j)-40).^2 + (Y(i,j) -40).^2) <D0
Z(i,j)=0;
elseif sqrt( (X(i,j)-40).^2 + (Y(i,j) -40).^2)>=D0
Z(i,j)=1;
end
end
end
figure(‘color’,[1,1,1])
mesh(X,Y,Z)
在这里插入图片描述
clc,clear,close all % 清理命令区、清理工作区、关闭显示图形
warning off % 消除警告
feature jit off % 加速代码运行
D0 = 10; % 阻止的频率点与频域中心的距离
x = 0:.5:80;
y = 0:.5:80;
[X,Y] = meshgrid(x,y);
u0 = 20;
v0 = 50;
for i=1:size(X,1)
for j=1:size(X,2)
if sqrt( (X(i,j)-u0).^2 + (Y(i,j) -v0).^2) <=D0 || sqrt( (X(i,j)-v0).^2 + (Y(i,j) -u0).^2) <=D0
Z(i,j)=0;
else
Z(i,j)=1;
end
end
end
figure(‘color’,[1,1,1])
mesh(X,Y,Z)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值