数字图像处理实验(7):PROJECT 04-03 , Lowpass Filtering
来源:互联网 发布:如何将相同的数据合并 编辑:程序博客网 时间:2024/06/05 05:50
实验要求:
Objective:
To observe how the lowpass filtering smoothes an image.
Main requirements:
Ability of programming with C, C++, or Matlab.
Instruction manual:
(a) Implement the Gaussian lowpass filter in Eq. (4.3-7). You must be able to specify the size, M x N, of the resulting 2D function. In addition, you must be able to specify where the 2D location of the center of the Gaussian function.
(b) Download Fig. 4.11(a) [this image is the same as Fig. 4.18(a)] and lowpass filter it to obtain Fig. 4.18(c).
实验要求我们通过在频域的高斯低通滤波器对图像进行低通滤波。
频域滤波的处理可以参考前面的实验04-01实现。(点我打开链接)
实验代码:
% PROJECT 04-03 Lowpass Filteringclose all;clc;clear all;%img = imread('Fig4.11(a).jpg');img = mat2gray(img);figure;subplot(1,3,1);imshow(img);title('原图像');% 产生滤波函数[M, N] = size(img);P = 2 * M;Q = 2 * N;alf = 100;H = zeros(P, Q);for i = 1:P for j = 1:Q H(i, j) = exp(-((i-P/2)^2 + (j-Q/2)^2) / (2 * alf^2)); endend% H = ones(P, Q);subplot(1,3,2);imshow(H);title('滤波函数');% % 图像填充[M, N] = size(img);P = 2 * M;Q = 2 * N;img_fp = zeros(P, Q);img_fp(1:M, 1:N) = img(1:M, 1:N);% [X, Y] = meshgrid(1:P, 1:Q);% ones = (-1)^(X+Y);% img_f = ones .* img_fp;img_f = zeros(P, Q);for x = 1:P for y = 1:Q img_f(x, y) = img_fp(x, y) .* (-1)^(x+y); endendimg_F = fft2(img_f);img_G = img_F .* H;img_g = real(ifft2(img_G));% img_g = ones .* img_g;for x = 1:P for y = 1:Q img_g(x, y) = img_g(x, y) .* (-1)^(x+y); endendimg_o = img_g(1:M, 1:N);subplot(1,3,3);imshow(img_o, []);title('高斯低通滤波后的图像');
其中套用公式产生高斯滤波函数的代码如下:
[M, N] = size(img);P = 2 * M;Q = 2 * N;alf = 100;H = zeros(P, Q);for i = 1:P for j = 1:Q H(i, j) = exp(-((i-P/2)^2 + (j-Q/2)^2) / (2 * alf^2)); endend
其余部分就是频率域滤波的流程,不做赘述。
实验结果:
说明:
第一幅图是原始图像;
第二幅是高斯低通滤波器;
第三幅是低通滤波处理后的结果,其较原始图像明显变得更模糊。
- 数字图像处理实验(7):PROJECT 04-03 , Lowpass Filtering
- 数字图像处理实验(8):PROJECT 04-04,Highpass Filtering Using a Lowpass Image
- 数字图像处理实验(3):PROJECT 02-03, Zooming and Shrinking Images by Pixel Replication
- 数字图像处理实验(12):PROJECT 05-03,Periodic Noise Reduction Using a Notch Filter
- 数字图像处理实验(16):PROJECT 06-03,Color Image Enhancement by Histogram Processing
- 数字图像处理实验(5):PROJECT 04-01 [Multiple Uses],Two-Dimensional Fast Fourier Transform
- 数字图像处理实验(6):PROJECT 04-02,Fourier Spectrum and Average Value
- 数字图像处理实验(9):PROJECT 04-05,Correlation in the Frequency Domain
- 数字图像处理实验(13):PROJECT 05-04,Parametric Wiener Filter
- 数字图像处理实验(17):PROJECT 06-04,Color Image Segmentation
- 数字图像处理实验(4):PROJECT 02-04 [Multiple Uses],Zooming and Shrinking Images by Bilinear Interpolation
- 数字图像处理实验(1):PROJECT 02-01, Image Printing Program Based on Halftoning
- 数字图像处理实验(10):PROJECT 05-01 [Multiple Uses],Noise Generators
- 数字图像处理实验(11):PROJECT 05-02,Noise Reduction Using a Median Filter
- 数字图像处理实验(14):PROJECT 06-01,Web-Safe Colors
- 数字图像处理实验(15):PROJECT 06-02,Pseudo-Color Image Processing
- bmp数字图像处理实验
- 数字图像处理实验综合
- Base64编码与解码原理和使用及复杂数据的存储
- Android性能优化工具Memory Monitor
- python爬虫
- Ubuntu 14.04 命令行非交互式安装 phpMyAdmin
- centos7 安装SSH
- 数字图像处理实验(7):PROJECT 04-03 , Lowpass Filtering
- Python scikit-learn机器学习工具包学习笔记:cross_validation模块
- css浏览器兼容问题
- buntu15.04设置自动锁屏时间
- POJ 1325 Machine Schedule 笔记
- struts2入门实例
- 26.struts2_文件的上传
- Git 命令
- chrome主页被篡改毒霸网址大全