实验四 图像复原及几何校正

一、实验目的:
1.掌握退化模型的建立方法。
2.掌握图像恢复的基本原理。
二、实验原理(略)

三、实验步骤(包括分析、代码和波形)
首先来看看这个实验的内容。实验主要内容如下:
(1)选择一幅清晰的灰度图像,对该图像进行模糊化处理并加入高斯噪声,然后分别采用逆滤波、维纳滤波和约束最小二乘方滤波对退化图像进行复原,比较各种图像的复原方法的复原效果。
(2)选择一幅清晰的灰度图像,对该图像进行仿射变换,如然后分别采用连接点选择、空间变换和灰度插值法对几何失真的图像进行复原,比较各种图像复原方法的复原效果。

下面是第(1)小题的代码。
代码一:

%% 仿真逆滤波、维纳滤波,约束最小二乘滤波
close all;
clear all;
clc;
% Display the original image.
I = imread('flower.jpg'); 
[d1,d2,d3] = size(I); 
if(d3 > 1) 
I = rgb2gray(I);
end
I = im2double(I);
[hei,wid,~] = size(I);
subplot(3,3,1),imshow(I);
title('Original Image ');
 
% Simulate a motion blur.
LEN = 50;
THETA = 11;
PSF = fspecial('motion', LEN, THETA);
blurred = imfilter(I, PSF, 'conv', 'circular');
subplot(3,3,2), imshow(blurred); title('Blurred Image');
 
% Simulate additive noise.
noise_mean = 0;
% noise_var = 0.00001;
noise_var = 0.0001;
blurred_noisy = imnoise(blurred, 'gaussian', ...
                        noise_mean, noise_var);
subplot(3,3,3), imshow(blurred_noisy)
title('Simulate Blur and Noise')
 
%% 使用自带的 deconvwnr 进行维纳滤波。 deconvreg进行约束最小二乘滤波
% deconvwnr 维纳滤波,如果没有参数NSPR,则为逆滤波
 
%自带 逆滤波 对已添加噪声图像 deconvwnr
deblurred4 = deconvwnr(blurred_noisy,PSF);
subplot(3,3,4), imshow(deblurred4); title('deconvwnr逆滤波 对 运动+噪声')
 
%自带 维纳滤波 对已添加噪声图像 deconvwnr
deblurred4 = deconvwnr(blurred_noisy,PSF,0.005); %0.005为噪声信号比
subplot(3,3,5), imshow(deblurred4); title('deconvwnr维纳滤波 对 运动+噪声')
 
%自带的 deconvreg 进行约束最小二乘滤波
subplot(3,3,6);
imshow(deconvreg(blurred_noisy, PSF,20)); %20 为噪声功率
title('deconvreg最小二乘滤波 对 运动+噪声');
 
%% 自写 逆滤波,约束最小二乘滤波
 
%自写 逆滤波 对未添加噪声图像
If = 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值