目录

目标

实验

主函数:加噪声,扭曲原始图片,使用滤波器修复图片

子函数1:中心化图片

子函数2:加高斯噪声

子函数3:维纳反卷积滤波器

子函数4:逆滤波器

实验结果

原始图片,退化图片,加噪图片,逆滤波修复图片,维纳反卷积滤波修复图片

维纳反卷积滤波器对高斯噪声variance的响应探究


目标

本实验使用自定义退化函数,对原始图片进行扭曲退化。然后使用逆滤波器和维纳反卷积滤波器来对退化图像处理,获得原始图片。

逆滤波是从系统的输出中接收输入的过程。一旦已知退化函数,这是恢复原始图像的最简单方法。

维纳反卷积滤波器定义

实验

主函数:加噪声,扭曲原始图片,使用滤波器修复图片

clc; clear;
%% Read the original image
fig_original = double(imread('data/book_cover.jpg')) / 255;
[Height, Width] =size(fig_original);
% Discrete Fourier Transformation
F = fft2(center_transform(fig_original));%% Blurring Degradation and Restoration
figure('Name', 'Blurring Degradation');
% Display the original image
subplot(2, 3, 1);
imshow(fig_original, []);
title('The original image');% Blur the image using paramaters a=b=0.1 and T = 1
subplot(2, 3, 2);
H = filter_H(Height, Width, 0.1, 0.1, 1);
blurred_image = center_transform(real(ifft2(H .* F)));
imshow(blurred_image, []);
imwrite(blurred_image, 'data/blurred_image.png');
title('Blurred image');% Add Gaussian noise of 0 mean and variance of 650 to the blurred image
subplot(2, 3, 3);
noise = gaussian_noise(Height, Width, sqrt(650), 0) / 255;
blurred_noisy_image = blurred_image + noise;
imshow(blurred_noisy_image, []);
imwrite(blurred_noisy_image, 'data/blurred_noisy_image.png');
title('Add Gaussian noise');% Restore the blurred image using the inverse filter
subplot(2, 3, 5);
F_blurred = fft2(center_transform(blurred_image));
blurred_restored = center_transform(real(ifft2(F_blurred ./ H)));
imshow(blurred_restored, []);
imwrite(blurred_restored, 'data/blurred_restored.png');
title('Blurred image restored with inverse filter');% Restore the blurred noisy image using Wiener deconvolution filter
subplot(2, 3, 6);
F_blurred_noisy = fft2(center_transform(blurred_noisy_image));
blurred_noisy_restored = center_transform(real(ifft2(wiener_filter(noise, F, H) .* F_blurred_noisy)));
imshow(blurred_noisy_restored, []);
imwrite(blurred_noisy_restored, 'data/blurred_noisy_restored.png');
title('Blurred noisy image restored with Wiener deconvolution filter');%% Investigate the performance of the Wiener deconvolution filter using Gaussian noise of 0 and different variances
figure('Name', 'Investigate Wiener deconvolution filter');% Add Gaussian noise of 0 mean and variance of 0.1 to the blurred image
subplot(1, 3, 1);
noise = gaussian_noise(Height, Width, sqrt(0.1), 0) / 255;
F_blurred_noisy = fft2(center_transform(blurred_image + noise));
blurred_noisy_restored = center_transform(real(ifft2(wiener_filter(noise, F, H) .* F_blurred_noisy)));
imshow(blurred_noisy_restored, []);
imwrite(blurred_noisy_restored, 'data/gvar0_1.png');
title('Gaussian variance = 0.1');% Add Gaussian noise of 0 mean and variance of 10 to the blurred image
subplot(1, 3, 2);
noise = gaussian_noise(Height, Width, sqrt(10), 0) / 255;
F_blurred_noisy = fft2(center_transform(blurred_image + noise));
blurred_noisy_restored = center_transform(real(ifft2(wiener_filter(noise, F, H) .* F_blurred_noisy)));
imshow(blurred_noisy_restored, []);
imwrite(blurred_noisy_restored, 'data/gvar10.png');
title('Gaussian variance = 10');% Add Gaussian noise of 0 mean and variance of 1000 to the blurred image
subplot(1, 3, 3);
noise = gaussian_noise(Height, Width, sqrt(1000), 0) / 255;
F_blurred_noisy = fft2(center_transform(blurred_image + noise));
blurred_noisy_restored = center_transform(real(ifft2(wiener_filter(noise, F, H) .* F_blurred_noisy)));
imshow(blurred_noisy_restored, []);
imwrite(blurred_noisy_restored, 'data/gvar1000.png');
title('Gaussian variance = 1000');

子函数1:中心化图片

function [ output ] = center_transform( input )
% CENTER_TRANSFORM centerize an image by applying
%   f(x, y) = f(x, y) * (-1)^{x+y}[h, w] = size(input);u = 1:h;v = 1:w;[V, U] = meshgrid(v, u);D = V + U;output = input .* power(-1, D);
end

子函数2:加高斯噪声

function [ output ] = gaussian_noise( M, N, sigma, zbar )
%GAUSSIAN_NOISE of size M * N
%   p(z) = 1 / sqrt(2 * pi)sigma * e^(-(z - zbar)^2 / 2sigma^2)output = zbar + randn(M, N) * sigma;
end

子函数3:维纳反卷积滤波器

function [ output ] = wiener_filter( N, F, H)
% WIENER_FILTER generates a typical Wiener filter by definitionH2 = abs(H) .^ 2;Sn = abs(fft2(center_transform(N))) .^ 2;Sf = abs(F) .^ 2;output = (H2 ./ H ./ (H2 + Sn ./ Sf));
end

子函数4:逆滤波器

function [ output ] = filter_H( M, N, a, b, T )
% FILTER_H generates a filter of size h * w
%   where H(u, v) = T / \pi(ua+vb) sin[\pi(ua+vb)] e^{-j\pi(ua+vb)}u = [1:M] - M / 2;v = [1:N] - N / 2;[V, U] = meshgrid(v, u);D = (V .* b + U .* a) .* pi;output = ones(M, N) .* T ./ D .* sin(D) .* exp(-j * D);output(D == 0) = 1;
end

实验结果

原始图片,退化图片,加噪图片,逆滤波修复图片,维纳反卷积滤波修复图片

维纳反卷积滤波器对高斯噪声variance的响应探究

数字图像处理之图像修复相关推荐

  1. 数字图像处理之图像基础

    最近在学数字图像处理,图像基础包括以下部分: 导入库 import numpy as np import matplotlib.pyplot as plt import cv2 as cv 图片展示函 ...

  2. 数字图像处理:图像的频域

    数字图像处理:图像的频域 一.图像高频信号和低频信号的理解 1.1 图像中的低频信号和高频信号也叫做低频分量和高频分量. 1)空间频率指的是图像中灰度值相对它的邻居点变化方式.如果一副图像中灰度从一边 ...

  3. 数字图像处理:图像金字塔

    转载请标明出处:数字图像处理:图像金字塔_数字图像处理opencv_新浪博客 (一)概念 以多个分辨率来表示图像的一种有效且概念简单的结构是图像金字塔.图像金字塔最初用于机器视觉和图像压缩,一个图像金 ...

  4. 数字图像处理 - Ch2 图像取样与量化

    数字图像处理 Ch2 图像取样与量化 图像取样与量化 概念 数字图像表示 线性索引与坐标索引 空间分辨率 & 灰度分辨率 图像内插 1. 最近邻内插 2. 双线性内插 3. 双三次内插 其他方 ...

  5. 数字图像处理--基本图像操作

    数字图像处理–基本图像操作 1 主要内容 (1)搭建能运行图像算法程序的平台: (2)独立完成matlab矩阵基本操作,如矩阵信息的提取包括获取矩阵大小.矩阵维数.矩阵元素个数.向量长度和矩阵乘法等操 ...

  6. 数字图像处理:图像的灰度变换(Matlab实现)

    数字图像处理:图像的灰度变换(Matlab实现) (1)线性变换: 通过建立灰度映射来调整源图像的灰度. k>1增强图像的对比度:k=1调节图像亮度,通过改变d值达到调节亮度目的:0 i = i ...

  7. 【数字图像处理】图像直方图均衡化、空域滤波(均值滤波、中值滤波)、图像锐化(Laplace算子)、图像傅里叶变换实验

    图像直方图均衡化.空域滤波.图像锐化.图像傅里叶变换 一.图像直方图均衡化 二.图像空域滤波 1.均值滤波(滤波次数n→3) 2.中值滤波(滤波次数n→3) 3.图像锐化(Laplace算子) 三.图 ...

  8. 数字图像处理(18): 图像灰度变换——线性灰度变换 和 非线性灰度变换(对数变换 与 伽马变换)

    目录 1 灰度变换简介 2 线性灰度变换­-图像反转 3 非线性灰度变换 3.1 对数变换 3.2 伽马变换 参考资料 1 灰度变换简介 灰度变换是图像增强的一种重要手段,用于改善图像显示效果,属于空 ...

  9. 数字图像处理之图像锐化算法

    图像锐化 图像锐化,主要用于增强图像的边缘,及灰度跳变部分.因为图像中边缘及急剧变化部分与图像的高频分量有关,所以当利用高通滤波器衰减图像信号中的低频分量时就会相对的强调其高频分量,从而加强图像中的边 ...

最新文章

  1. 官方解读,谷歌“T5”模型,如何突破迁移学习局限,实现多基准测试SOTA
  2. python 100题
  3. 小甲鱼-013元组tuple:上了枷锁的列表
  4. React 实现一个漂亮的 Table
  5. 如何在Spring生态中玩转RocketMQ?
  6. Linux网络监控工具nethogs
  7. 运维部门工作总结_运维部工作总结
  8. javaweb零食商城系统设计与实现(ssm项目)(含论文和源码)
  9. 微信小程序上传图片到云储存
  10. 什么是 0day 漏洞,1day 漏洞和 nday 漏洞?
  11. 深圳市商务局2022年度中央资金(跨境电子商务企业市场开拓扶持事项)申报指南
  12. 软件项目管理与素质拓展-2.2什么是项目
  13. 豫科技版计算机七年级上册,七年级下册信息技术教案第一单元第一课《制作新春灯笼》豫科技版.doc...
  14. Java获得指定时区时间
  15. 收藏 | 机器学习分类算法
  16. ResNet详解:ResNet到底在解决什么问题?
  17. Python网络相关面试题
  18. Consumer翻译
  19. Lettuce(基于Python的BDD工具,中文编写自动化测试用例)
  20. Linux 下进行服务器间网络测速

热门文章

  1. linux智能电压表设计与实现,智能电压表的设计
  2. *++pt;++*pt;(*pt)++;*pt++的区别
  3. 企业微信集成EAS流程助手
  4. 爬虫练习:爬取网易云音乐热歌榜全部歌曲的热门评论
  5. 【EPS\AI】12款教师节手绘海报矢量模版素材
  6. hawk大数据基础知识总结(1)
  7. 歪门邪道 Leetcode 463 Island Perimeter
  8. 哈尔滨理工大学第七届程序设计竞赛决赛(网络赛-高年级组)G - 幼儿园战争...
  9. 服务器打不开微信怎么办,手机wifi只能用微信,打不开网页怎么处理?
  10. 遗传算法求解一元函数最大值