哈⼯⼤深研院数字图像处理第⼀次⼤作业:不调⽤Matlab现有
库函数实现图像增强
写完作业了过来Mark⼀记~
题⽬是:
Image Enhancement
1. Histogram Equalization: Write a program for computing the histogram of the image (a) and implement the histogram equalization technique as we discussed in the class.
2. Remove the noise from the image (c).
3. Filtering in the Frequency Domain: Implement the Gaussian highpass filters on test image (e).
Attention:
1. Don’t use any commercial tools such as matlab functions, Open CV or other library (except FFT functions). Please do it by c/c++, java or other languages.
2. Source codes and projects are required when you submit your report. Submitting names will be
‘Pro1_studentnumber_name.zip/rar’.
3. Each student should independently finish this work.
4. Deadline: 2016-04-20.
5. All test images can be downloaded from the QQ group.
⽽本宝宝的报告是:
汇报⼈:EMPTY 学号:EMPTY 班级:电⼦与通信⼯程
程序清单:
1.Histogram_Equalization.m
2.Noise_Remove.m
3.Gaussian_Highpass_Filtering.m
程序说明:
1.依据灰度直⽅图均衡化处理原理,我⾸先得到了原始图像的灰度直⽅图Fig.1(a),从图像中我们可以看到,图像灰度集中分布于灰度值较低的区域,表现在图像上Fig.2我们可以看出整幅图像颜⾊昏暗,对⽐度不⾼,为了解决这个问题,我们采⽤图像直⽅图均衡化的处理⽅法,分别计算出每个灰度出现的频率和概率,并利⽤离散积分函数:S_k=(L-1)/MN ∑_(j=0)^(k-1)▒n_j ,k=0,1,2,…,L-1(1)
计算出灰度的累积分布情况。利⽤这个分布,构造出原始灰度向均衡化灰度转换的映射关系,并利⽤这种映射关系来对灰度图像进⾏均衡化处理。最终可以得到灰度直⽅图分布如Fig.1(b)所⽰的灰度分布以及Fig.3所⽰的处理后结果。
2.针对Fig.4中存在的椒盐噪声,采⽤中值滤波可以达到很好的滤除效果。通过构建
1 1 1
1 1 1
1 1 1
这样的模板,将模板内的中值替代为模板中⼼的图像值,使这个模板扫过整幅图像便可以实现噪声滤除效果。同时,由于边界效应,我们将图像的边界进⾏了扩充。实践证明图像边界的扩充可以在处理后通过恰当的处理结果裁剪⽽消除影响,并且这种扩充对于图像来说将不会造成影响。这⾥有⼏点需要注意:
1)模板的维度必须是奇数维正⽅形,否则将会在模板中⼼选取时造成很⼤的困扰;
2)模板⼤⼩应当与需要处理的椒盐噪声的尺⼨有关,同时,越⼤的模板将会对图像处理结果造成越模糊的影响。通过测试发现选⽤3*3的模板恰好可以满⾜本实验的要求;
3)针对中值选取,⽤于不允许使⽤Matlab⾃带的median以及sort函数,我采⽤了冒泡排序的⽅法,因为Matlab软件本⾝对于for循环处理的速度较慢,所以整个图像的处理速度显得较慢。
3.针对题⽬3中要求的的图像锐化,可以采⽤⾼斯⾼通滤波器进⾏锐化处理。通过构造图像Fig.6所对应的归⼀化频率分布,构造空间频率分布,利⽤⾼斯⾼通滤波器表达式(GHPF):
H(u,v)=1-e^(-(D^2 (u,v))/(2〖D_0〗^2 )) (2)
构造传递函数H(u,v),对原始图像x(m,n)进⾏频谱对称化(fftshift)后的快速傅⾥叶变换(FFT),再与传递函数相乘得到处理后的结果
Y(u,v),最终对该结果进⾏逆傅⾥叶变换,得到我们需要的锐化图像y(m,n)。如图Fig.7所⽰。
程序代码也给⼤家贴上来好了1.
%Name:Histogram_Equalization
%function:对直⽅图进⾏均衡化处理实现图像增强
%Author:Changle Zhang
matlab直方图%Student ID:15S158746
clear all;
close all;
clc; %Initialization
fig = imread('a.jpg'); %import the image
subplot(121)
plot(fig);
title('(a)Gray distribution of image befort process');
[row,col] = size(fig); %Image size
PixelsNum = row * col; %Number of Pixels
freq = zeros(256,1); %record frequency of each gray level
prob = zeros(256,1); %record probability of each gray level
%calculate frequency and probability
for i = 1:row
for j= 1:col
value = fig(i,j);
freq(value+1) = freq(value+1) + 1;
prob(value+1) = freq(value+1) / PixelsNum;
end
end
cums = zeros(256,1); %record the cumulative distribution probc = zeros(256,1); %record the probability of each distribution output = zeros(256,1); %gray level after H_E
counter = 0;
graylevel = 255;
%calculate cumulative distribution and output gray level
for i = 1:size(prob)
counter = counter + freq(i);
cums(i) = counter;
probc(i) = cums(i) / PixelsNum;
output(i) = round(probc(i) * graylevel);
end
%HE process
outputimage = uint8(zeros(row,col)); %Final image
for i = 1:row
for j = 1:col
outputimage(i,j) = output(fig(i,j)+1);
end
end
%outputing
subplot(122)
plot(outputimage);
title('(b)Gray distribution of image after process');
figure
imshow(fig);
title('Image before histogram equalization');
figure
imshow(outputimage);
title('Image after histogram equalization');
2.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论