-
图像处理中平滑中值锐化matlab代码
2012-05-03 10:50:15完整的平滑中值锐化代码,详细的注释,更好的了解程序 -
用matlab编程实现对图像的均值滤波,中值滤波和拉普拉斯算子锐化
2020-03-30 21:19:432 中值滤波 中值滤波:先将掩模内欲求的像素及其领域的像素值排序(升序或降序),确定出中值,并将中值赋予该像素点。 强迫突出的亮点(暗点)更象它周围的值,以消除孤立的亮点(暗点)。 二维中值滤波的窗口形状...1 均值滤波
- 均值滤波:用包含在滤波掩模邻域内的像素的平均灰度值去代替每个像素点的值。
- 用途:用于模糊处理和减少噪声。
盒滤波器:
加权平均滤波器
% 均值滤波 clc;close all;clear all; I = rgb2gray(imread('fig.png')); F = imnoise(I,'gaussian',0, 0.02); % 加入高斯噪声 % F = imnoise(I,'salt & pepper',0.02); %加入椒盐躁声 v = 1/9*[1 1 1;1 1 1;1 1 1]; % 盒滤波器 v2 = 1/16*[1 2 1;2 4 2;1 2 1]; % 加权平均滤波器 [m, n] = size(I); G = zeros(m,n); H = zeros(m,n); for x=1:m for y = 1:n if (x==1||y==1||x==m||y==n) G(x,y)=F(x,y); H(x,y)=F(x,y); else % 对图像进行卷积处理 G(x,y)=v(1,1) * F(x-1, y-1) + v(1,2) * F(x-1, y)+v(1,3) *F(x-1, y+1)... +v(2,1) * F(x, y-1)+v(2,2)* F(x, y)+v(2,3) * F(x, y+1)... +v(3,1) * F(x+1, y+1) + v(3,2) * F(x+1, y)+v(3,3)* F(x+1, y+1); H(x,y)=v2(1,1) * F(x-1, y-1) + v2(1,2) * F(x-1, y)+v2(1,3) * F(x-1, y+1)... +v2(2,1) * F(x, y-1)+v2(2,2)* F(x, y)+v2(2,3) * F(x, y+1)... +v2(3,1) * F(x+1, y+1) + v2(3,2) * F(x+1, y)+v2(3,3) * F(x+1, y+1); end end end figure subplot(221) imshow(I); title('原始图像'); subplot(222) imshow(uint8(F)); % title('加入椒盐噪声后的图像'); title('加入高斯噪声后的图像'); subplot(223) imshow(uint8(G)); title('均值滤波后的图像'); subplot(224) imshow(uint8(H)); title('加权均值滤波后的图像');
2 中值滤波
- 中值滤波:先将掩模内欲求的像素及其领域的像素值排序(升序或降序),确定出中值,并将中值赋予该像素点。
- 强迫突出的亮点(暗点)更象它周围的值,以消除孤立的亮点(暗点)。
- 二维中值滤波的窗口形状和尺寸对滤波效果影响较大,不同的图像内容和不同的应用要求,往往采用不同的窗口形状和尺寸。常用的二维中值滤波窗口有线状、方形、圆形、十字形以及圆环形等。窗口尺寸一般先用3×3,再取5×5逐渐增大,直到滤波效果满意为止。就一般经验来讲,对于有缓变的较长轮廓线物体的图像,采用方形或圆形窗口为宜。对于包含有尖顶物体的图像,用十字形窗口,而窗口大小则以不超过图像中最小有效物体的尺寸为宜。如果图像中点、线、尖角细节较多,则不宜采用中值滤波。
- 主要功能:使拥有不同灰度的点看起来更接近于它的邻近值。
- 用途:去除椒盐噪声
% 中值滤波 clc;close all;clear all; I = rgb2gray(imread('fig.png')); % F = imnoise(I,'gaussian',0, 0.002); F = imnoise(I,'salt & pepper',0.06); [m, n] = size(I); G = zeros(m,n); for x=1:m for y = 1:n if (x==1||y==1||x==m||y==n) G(x,y)=F(x,y); else % 选出第5大的数 H = sort([F(x-1,y-1), F(x-1,y),F(x-1,y+1),F(x,y),... F(x,y+1),F(x+1,y-1),F(x+1,y),F(x+1,y+1)]); G(x,y)=median(H); end end end figure subplot(221) imshow(I); title('原始图像'); subplot(222) imshow(uint8(F)); title('加入椒盐噪声后的图像'); subplot(223) imshow(uint8(G)); title('中值滤波后的图像');
3 拉普拉斯算子锐化
- 拉普拉斯微分算子强调图像中灰度的突变,弱化灰度慢变化的区域。这将产生一幅把浅灰色边线、突变点叠加到暗背景中的图像。
- 对二元图像函数f(x,y)的拉普拉斯变换定义为:
对应的掩模为:
微分掩模的所有系数之和为0以保证灰度恒定区域的响应为0将原始图像和拉普拉斯图像叠加在一起的简单方法可以保护拉普拉斯锐化处理的效果,同时又能复原背景信息。因此拉普拉斯算子用于图像增强的基本方法如下:
clc;close all;clear all; F = rgb2gray(imread('fig.png')); [m,n]=size(F); G=zeros(m,n); H=zeros(m,n); w=[0,-1,0;-1,4,-1;0,-1,0]; for x=1:m for y=1:n if (x==1||y==1||x==m||y==n) G(x,y)=F(x,y); else G(x,y)=w(1,1)*F(x-1,y-1)+w(1,2)*F(x-1,y)+w(1,3)*F(x-1,y+1)... +w(2,1)*F(x,y-1)+w(2,2)*F(x,y)+w(2,3)*F(x,y+1)... +w(3,1)*F(x+1,y+1)+w(3,2)*F(x+1,y)+w(3,3)*F(x+1,y+1); end end end figure subplot(121) imshow(F) title('原始图像'); subplot(122) imshow(uint8(G)); title('拉普拉斯算子处理后的图像');
-
中值滤波、均值滤波、灰度图像的锐化处理(包括Sobel、Prewitt、Roberts、Laplace、Canny边缘检测)...
2020-08-03 12:36:12目录1 原理1.1 中值滤波1.2 均值滤波1.3 图像锐化1.4 边缘检测2 实现源代码(MATLAB)2.1 中值滤波2.2 均值滤波2.3 锐化处理2.3.0 说明2.3.1 Laplace算子2.3.2 Sobel算子2.3.3 Prewitt算子2.3.4 Roberts算子2.4 边缘...目录
1 原理
1.1 中值滤波
主要用来处理椒盐噪声。椒盐噪声的出现使得该点像素比周围的像素亮(暗)很多,而如果在某个模板中对像素由小到大进行重新排列,那么最亮的或者最暗的点一定被排在两侧。这时取模板中排在中间位置上的像素的灰度值替代待处理像素的值,就可以达到滤除噪声的目的。
- 将模板中心与像素位置重合
- 读取模板下各对应像素的灰度值
- 将这些像素从小到大排成1列
- 找出这些值里排在中间的1个
- 将这个中间值赋给模板中心位置像素。
1.2 均值滤波
采用邻域平均法。基本思想是用几个像素灰度的平均值来代替每个像素的灰度。如使用一个3*3大小的模板对图像进行滤波,每次移动模板后,对模板范围内的所有像素灰度值相加再除以系数9,四舍五入后作为模板中心像素的灰度值。
1.3 图像锐化
图像锐化的目的是为了突出图像的边缘信息,加强图像的轮廓特征,便于人眼或者机器的识别。图像中边缘和轮廓往往出现于图像中灰度图片的地方,而检查这些图片可以用微分实现,因而图像锐化主要是通过微分方法进行的。
由于处理的对象是数字图像,其像素是离散的,对微分形式进行一些近似处理,得到离散的模板矩阵,称为算子。常见的算子诸如Laplacians、Roberts、Sobel等。用这些算子作为模板对图像进行处理,就能得到图像的轮廓图。将轮廓图与原图像相加即可得到原图像的锐化结果。1.4 边缘检测
在图像锐化得到的轮廓图的基础上,根据轮廓图的灰度直方图设立阈值(一般在两峰一谷之间),对其进行二值化处理即可。
2 实现源代码(MATLAB)
2.1 中值滤波
function res = medianfilter(mat, width, height) % res = medianfilter(img, width, height) % -- res the result of the median filter process % -- img the input image matrix(should be 2 dimensions) % -- width the width of template % -- height the height of template % e.g.: % filename='noise.jpg'; % img=imread(filename); % width=3;height=3; % res = medianfilter(img, width, height); % imshow(res); % mkdir('results/medianfilter'); % imwrite(res,['./results/medianfilter/',filename]); res=im2uint8(zeros(size(mat))); [rows,cols]=size(mat); for i = 1:(rows-height + 1) for j = 1:(cols-width + 1) temp = mat(i:i+height-1, j:j+width-1); temp = sort(temp(:)); res((i+i+height-1)/2, (j+j+width-1)/2) = temp((length(temp)+1)/2); end end
2.2 均值滤波
function res = meanfilter(mat, width, height) % res = medianfilter(img, width, height) % -- res the result of the median filter process % -- img the input image matrix(should be 2 dimensions) % -- width the width of template % -- height the height of template % e.g.: % filename='noise.jpg'; % img=imread(filename); % width=3;height=3; % res = meanfilter(img, width, height); % imshow(res); % mkdir('results/meanfilter'); % imwrite(res,['./results/meanfilter/',filename]); res=im2uint8(zeros(size(mat))); [rows,cols]=size(mat); for i = 1:(rows-height + 1) for j = 1:(cols-width + 1) temp = mat(i:i+height-1, j:j+width-1); res((i+i+height-1)/2, (j+j+width-1)/2) = round(mean(temp(:))); end end
2.3 锐化处理
2.3.0 说明
在分别实现使用Sobel、Prewitt、Roberts、Laplace算子的滤波函数后,希望实现一个“万能滤波函数”。
搜索得知MATLAB内置的滤波函数为imfilter,支持输入图像、模板等参数,输出滤波后结果。其对“最外面一圈像素”的处理方式是在最外层“加一圈0像素”,并对全图像进行处理。
仿照其功能实现myfilter函数,代码如下:function res=myfilter(I,H) % function res=myfilter(I,H) % -- res the result of the filter process % -- I the input image % -- H the input template matrix(should be 2 dimensions) % e.g.: % filename='锐化及边缘检测用途.jpg'; % I=imread(filename); % H=[1,1,1;1,-8,1;1,1,1]; % res=myfilter(I,H); % imshow(res); % mkdir('results/myfilter'); % imwrite(res,['./results/myfilter/',filename]); I=im2uint8(I); H=int16(H); [rows,cols,channels]=size(I); res=uint8(zeros(rows,cols,channels)); [height,width]=size(H); hh=(height+1)/2; hw=(width+1)/2; for k=1:channels chan=int16(zeros(rows+hh,cols+hw)); chan(hh:rows+hh-1,hw:cols+hw-1)=I(:,:,k); for i=1:rows for j=1:cols temp=chan(i:i+hh,j:j+hw); res(i,j,k)=sum(sum(H.*temp)); end end end
通过如下代码实现两者效果对比:
I=imread('锐化及边缘检测用途.jpg'); H=[1,1,1;1,-8,1;1,1,1]; imres=imfilter(I,H); myres=myfilter(I,H); cmp=(imres==myres); length(cmp(cmp==0))
得到结果为:
ans = 0
于是复用myfilter函数,以另一种方式实现了Sobel、Prewitt、Roberts、Laplace算子滤波函数,在原命名后添加了“2”以区分。
需要注意的是,myfilter最多算是imfilter的一个弱化版本,运行速度远不及imfilter。另外,经查阅,imfilter默认使用的是’corr’参数,而不是’conv’,即默认使用的不是卷积运算。但本实验遇到的算子(Sobel、Prewitt、Laplace)模板都可以认为是对称的,实验得知本实验中对这三类算子在’conv’和’corr’两种参数下结果是完全一致的,故myfilter也没有提供诸如’corr’和’conv’之类参数的支持(即不支持模板矩阵不对称的卷积运算,仅支持相关运算)。2.3.1 Laplace算子
采用的laplacian operator为[1,1,1;1,-8,1;1,1,1],故若要得到锐化图像,应该使用原图像减去该函数计算结果再输出。
function laplacian=laplacianfilter(image) % function laplacian=laplacianfilter(image) % -- laplacian the result of the laplacian operator filter process % -- image the input image % e.g.: % filename='锐化及边缘检测用途.jpg'; % img=imread(filename); % res=laplacianfilter(img); % imshow(res); % mkdir('results/laplacianfilter'); % imwrite(res,['./results/laplacianfilter/',filename]); image=im2uint8(image); [rows,cols,channels]=size(image); laplacian=uint8(zeros(rows,cols,channels)); for k=1:channels chan=int16(zeros(rows+2,cols+2)); chan(2:rows+1,2:cols+1)=image(:,:,k); for i=1:rows for j=1:cols temp=chan(i:i+2, j:j+2); laplacian(i,j,k)=sum(temp(:))-9*chan(i+1,j+1); end end end
复用myfilter函数实现:
function laplacian=laplacianfilter2(image) % function laplacian=laplacianfilter2(image) % -- laplacian the result of the laplacian operator filter process % -- image the input image % e.g.: % filename='锐化及边缘检测用途.jpg'; % img=imread(filename); % res=laplacianfilter2(img); % imshow(res); % mkdir('results/laplacianfilter'); % imwrite(res,['./results/laplacianfilter/',filename]); laplacianoperator=[1,1,1;1,-8,1;1,1,1]; laplacian=myfilter(image,laplacianoperator);
2.3.2 Sobel算子
function sobel=sobelfilter(image) % function sobel=sobelfilter(image) % -- sobel the result of the sobel operator filter process % -- image the input image % e.g.: % filename='锐化及边缘检测用途.jpg'; % img=imread(filename); % res=sobelfilter(img); % imshow(res); % mkdir('results/sobelfilter'); % imwrite(res,['./results/sobelfilter/',filename]); sobeloperator1=int16([-1,0,1;-2,0,2;-1,0,1]); sobeloperator2=int16([-1,-2,-1;0,0,0;1,2,1]); image=im2uint8(image); [rows,cols,channels]=size(image); sobel1=uint8(zeros(rows,cols,channels)); sobel2=uint8(zeros(rows,cols,channels)); for k=1:channels chan=int16(zeros(rows+2,cols+2)); chan(2:rows+1,2:cols+1)=image(:,:,k); for i=1:rows for j=1:cols temp=chan(i:i+2,j:j+2); sobel1(i,j,k)=sum(sum(sobeloperator1.*temp)); sobel2(i,j,k)=sum(sum(sobeloperator2.*temp)); end end end sobel=abs(sobel1)+abs(sobel2);
复用myfilter函数实现:
function sobel=sobelfilter2(image) % function sobel=sobelfilter2(image) % -- sobel the result of the sobel operator filter process % -- image the input image % e.g.: % filename='锐化及边缘检测用途.jpg'; % img=imread(filename); % res=sobelfilter2(img); % imshow(res); % mkdir('results/sobelfilter'); % imwrite(res,['./results/sobelfilter/',filename]); sobeloperator1=[-1,0,1;-2,0,2;-1,0,1]; sobeloperator2=[-1,-2,-1;0,0,0;1,2,1]; sobel=myfilter(image,sobeloperator1)+myfilter(image,sobeloperator2);
2.3.3 Prewitt算子
function prewitt=prewittfilter(image) % function prewitt=prewittfilter(image) % -- prewitt the result of the prewitt operator filter process % -- image the input image % e.g.: % filename='锐化及边缘检测用途.jpg'; % img=imread(filename); % res=prewittfilter(img); % imshow(res); % mkdir('results/prewittfilter'); % imwrite(res,['./results/prewittfilter/',filename]); image=im2uint8(image); [rows,cols,channels]=size(image); prewitt1=uint8(zeros(rows,cols,channels)); prewitt2=uint8(zeros(rows,cols,channels)); for k=1:channels chan=int16(zeros(rows+2,cols+2)); chan(2:rows+1,2:cols+1)=image(:,:,k); for i=1:rows for j=1:cols temp=chan(i+2,j:j+2)-chan(i,j:j+2); prewitt1(i,j,k)=sum(temp(:)); temp=chan(i:i+2,j+2)-chan(i:i+2,j); prewitt2(i,j,k)=sum(temp(:)); end end end prewitt=prewitt1+prewitt2;
复用myfilter函数实现:
function prewitt=prewittfilter2(image) % function prewitt=prewittfilter2(image) % -- prewitt the result of the prewitt operator filter process % -- image the input image % e.g.: % filename='锐化及边缘检测用途.jpg'; % img=imread(filename); % res=prewittfilter2(img); % imshow(res); % mkdir('results/prewittfilter'); % imwrite(res,['./results/prewittfilter/',filename]); prewittoperator1=[-1,-1,-1;0,0,0;1,1,1]; prewittoperator2=[-1,0,1;-1,0,1;-1,0,1]; prewitt=myfilter(image,prewittoperator1)+myfilter(image,prewittoperator2);
2.3.4 Roberts算子
为方便计算,将Roberts算子修改为3*3矩阵,复用myfilter函数实现:
function roberts=robertsfilter2(image) % function roberts=robertsfilter2(image) % -- roberts the result of the laplacian operator filter process % -- image the input image % e.g.: % filename='锐化及边缘检测用途.jpg'; % img=imread(filename); % res=robertsfilter2(img); % imshow(res); % mkdir('results/robertsfilter2'); % imwrite(res,['./results/robertsfilter2/',filename]); robertsoperator1=[0,0,0;0,-1,0;0,0,1]; robertsoperator2=[0,0,0;0,0,-1;0,1,0]; roberts=myfilter(image,robertsoperator1)+myfilter(image,robertsoperator2);
2.4 边缘检测
同样地,参考MATLAB内置边缘检测函数edge实现了其一个简化版本myedge:支持直接输入模板矩阵,或者输入字符串以调用对应模板矩阵;没有自动阈值选择,需要手动输入)。代码如下:
function res=myedge(img,operator,threshold) % function res=myedge(img,operator,threshold) % -- res the edge result of the input image % -- image the input image % -- operator the input operator(should be 2 dimensional odd-order matrix) or string like 'laplacian'/'sobel'/'prewitt'/'roberts' % -- threshold threshold to decide whther a pixel on the edge should be black or white % e.g.: % filename='锐化及边缘检测用途.jpg'; % img=imread(filename); % operator='laplacian'; % threshold=233; % res=myedge(img,operator,threshold); % imshow(res); % mkdir(['results/myedge/',operator]); % imwrite(res,['./results/myedge/',operator,'/',filename]); if ischar(operator) switch operator case 'laplacian' res=laplacianfilter2(img); case 'sobel' res=sobelfilter2(img); case 'prewitt' res=prewittfilter2(img); case 'roberts' res=robertsfilter2(img); end else res=myfilter(img,operator); end res(res<threshold)=0;res(res>=threshold)=255;
3 实验结果
3.1 中值滤波(使用3*3大小模板)
编写了通用函数,可以在输入参数中指定模板大小。
3.2 均值滤波(使用3*3大小模板)
编写了通用函数,可以在输入参数中指定模板大小。
3.3 锐化处理(注:锐化效果未叠加到原图,展示图为轮廓图)
3.3.0原图
3.3.1 Laplace算子
3.3.2 Sobel算子
3.3.3 Prewitt算子
3.3.4 Roberts算子
3.4 边缘检测
以laplacian operator为模板矩阵,阈值为233。其余结果类似,可参照help myedge中的例子,调用myedge函数生成。
注:遇到的一个问题是,边缘检测应当是只有0和255两种灰度的图像,在MATLAB中生成以后使用imshow查看没有问题,但保存为.jpg格式后出现了其他灰色。再次读取该.jpg图片,数值上与原来MATLAB生成图像并不一致,猜测可能是压缩编码为.jpg格式时出现了损失。
-
MATLAB图像处理之图像的均值滤波和中值滤波(附代码)
2020-04-16 16:48:39图像的平滑、锐化都是利用掩模操作来完成的。通过掩模操作实现一种邻域运算,待处理像素点的结果由邻域的图像像素以及相应的与邻域有相同维数的子图像得到。这些子图像被称为滤波器、掩模、核、模板或窗口; 掩模...图像的平滑、锐化都是利用掩模操作来完成的。通过掩模操作实现一种邻域运算,待处理像素点的结果由邻域的图像像素以及相应的与邻域有相同维数的子图像得到。这些子图像被称为滤波器、掩模、核、模板或窗口;
掩模运算的数学含义是卷积(或互相关)运算;
掩模子图像中的值是系数值,而不是灰度值;
卷积示例图:
一般来说,在MN的图像f(x,y)上,用mn大小的滤波器掩模进行线性滤波由下式给出:
模板为1*5的中值滤波和均值滤波的对比:
均值滤波
简单来说就是对某个区域内的像素值取平均值代替原像素值
常用的3*3的滤波器掩模为:
一幅M×N的图像经过m×n的加权均值滤波器滤波的过程可由下式给出:
一般选取n*n的模板,便于运算,下面给出示例代码:img = imread(''); [M , N] = size(img);%图片尺寸 img_result = zeros(M, N);%预生成,提高速度 muban_size = 3;%模板尺寸 expand_size = floor(muban_size / 2);%扩展尺寸 muban = 1 / (muban_size * muban_size) .* ones(muban_size, muban_size); expand_img = double(wextend('2D','zpd', img, expand_size));%扩展0,转double为了矩阵运算 for i=1:M for j=1:N ave = sum( sum( expand_img(i:i+muban_size-1,j:j+muban_size-1) .* muban)); %取出扩展元素与模板相乘,并求矩阵元素之和 img_result(i,j) = ave; end end img_result = uint8(img_result);%转int8,图像 subplot(1 ,2, 1); title('原图像') imshow(img) subplot(1 ,2, 2); imshow(img_result) da = ['模板大小为' num2str(muban_size) ',变化后的图像']; title(da)
结果示例:
可见均值滤波对于噪声有一定的抑制作用,但是会出现部分的涂抹感。中值滤波
中值滤波和均值滤波不同的地方是,中值滤波是对图像的像素值进行排序,取中间的像素值赋给新的图像。
主要功能:使拥有不同灰度的点看起来更接近于它的邻近值。
主要用途:去除“椒盐”噪声示例代码:
img = imread(''); [M , N] = size(img);%图片尺寸 img_result = zeros(M, N);%预生成,提高速度 muban_size = 3;%模板尺寸 expand_size = floor(muban_size / 2);%扩展尺寸 muban = ones(muban_size, muban_size); expand_img = double(wextend('2D','zpd', img, expand_size));%扩展0,转double为了矩阵运算 for i=1:M for j=1:N mat = expand_img(i:i+muban_size-1,j:j+muban_size-1) .* muban; %取出x1中从(i,j)开始的n行n列元素与模板相乘 mat = mat(:);%转数组 mat = sort(mat);%排序 if mod(muban_size, 2)==1 img_result(i,j) = mat(floor(muban_size*muban_size/2)+1);%取中间 else img_result(i,j) = (mat(muban_size*muban_size/2) + mat(muban_size*muban_size/2+1))/2; end end end img_result = uint8(img_result);%转int8,图像 subplot(1 ,2, 1); title('原图像') imshow(img) subplot(1 ,2, 2); imshow(img_result) da = ['模板大小为' num2str(muban_size) ',变化后的图像']; title(da)
结果示例:
效果好像特别好。一些其他的中值滤波器:
另:
中值滤波的窗口形状和尺寸对滤波效果影响较大,不同的图像内容和不同的应用要求,往往采用不同的窗口形状和尺寸。常用的二维中值滤波窗口有线状、方形、圆形、十字形以及圆环形等。
窗口尺寸一般先用3X3,再取5X 5逐渐增大,直到滤波效果满意为止。就经验来讲,对于有缓变的较长轮廓线物体的图像,采用方形或圆形窗口为宜。对于包含有尖顶物体的图像,用十字形窗口,而窗口大小则以不超过图像中最小有效物体的尺寸为宜。如果图像中点、线、尖角细节较多,则不宜采用中值滤波最后,点个赞?
-
matlab图像增强程序(平滑和锐化)
2016-10-26 21:13:06利用matlab编写的图像平滑锐化程序,包括:'均值滤波','中值滤波','罗伯特梯度','Prewitt算法','Sobel梯度','Laplace算子','Laplace算子扩展模板','方向算子' -
图像的平滑和锐化 matlab
2012-05-03 21:09:22锐化处理技术来加强图像的目标边界和图像细节。对图像进行梯度算子、Roberts算子、Sobel算子边缘检测处理和Laplace算子边缘增强处理,是图像的某些特征(如边缘、轮廓等)得以进一步的增强及突出。 图像平滑主要目的是... -
数字图像处理-滤波&边缘检测&锐化&RGB转HSI(Matlab)
2020-11-01 22:19:05文章目录数字图像处理-图像增强(Matlab)1、对选定的灰度图像进行反色、线性变换、对数变换等基本处理。(线性变换函数自设)1.1 灰度反转1.2 线性变换1.3 对数变换2、对选定的灰度图像进行直方图均衡化处理,并显示...文章目录
- 数字图像处理-图像增强(Matlab)
- 1、对选定的灰度图像进行反色、线性变换、对数变换等基本处理。(线性变换函数自设)
- 2、对选定的灰度图像进行直方图均衡化处理,并显示处理前后的直方图。
- 3、分别在两幅灰度图像中加入一定量的高斯噪声和椒盐噪声,噪声强度自定。然后分别采用3x3的均值滤波和3x3中值滤波对噪声进行处理,显示结果图像,并计算出两种处理方法的峰值信噪比(PSNR)。
- 4、对选定的灰度图像进行锐化处理:先对原图像进行3*3均值滤波使其模糊,再分别通过Roberts算子、Sobel算子、拉普拉斯算子对其进行边缘增强处理,显示结果图像并对比各方法的结果
- 5、对选定的灰度图像进行巴特沃斯高通滤波处理:要求设定多种不同(高、中、低)的截止频率进行滤波,显示其经滤波后的空域图像
- 6、对选定的灰度图像进行理想低通滤波处理:要求设定多种不同(高、中、低)的截止频率进行滤波,显示其经滤波后的空域图像。
- 7、对选定的一幅RGB彩色图像(BMP格式),分别显示该图的R/G/B单色图像,绘制R/G/B单色图像的直方图;将RGB彩色模式转换为HIS模式,再显示该图的H/I/S三个分量的图像。
- 8、对一幅彩色RGB图像,采用对每一彩色分量进行拉普拉斯算子滤波,完成图像锐化处理。
数字图像处理-图像增强(Matlab)
1、对选定的灰度图像进行反色、线性变换、对数变换等基本处理。(线性变换函数自设)
1.1 灰度反转
- 原理公式
- Matlab代码块:
%-------------------------灰度反转(Matlab代码)----------------------- clc; %清空控制台 clear; %清空工作区 close all; %关闭已打开的figure图像窗口 color_pic=imread('lena512color.bmp'); %读取彩色图像 gray_pic=rgb2gray(color_pic); %将彩色图转换成灰度图 gray_reversal=256-1-gray_pic; % g(x,y)=L-1-f(x,y) 此图灰度级数L为256级 figure('name','灰度反转'); subplot(1,2,1);imshow(gray_pic,[]);title('原灰度图'); subplot(1,2,2);imshow(gray_reversal,[]);title('灰度反转图');
- 运行效果:
1.2 线性变换
- 线性函数
- Matlab代码块:
%-------------------------线性变换(Matlab代码)------------------------ clc; %清空控制台 clear; %清空工作区 close all; %关闭已打开的figure图像窗口 color_pic=imread('lena512color.bmp'); %读取彩色图像 gray_pic=rgb2gray(color_pic); %将彩色图转换成灰度图 double_gray_pic=im2double(gray_pic); linear_transform_reduce=double_gray_pic*tan(pi/6); %g(x,y)=f(x,y)*tan(a) 线性变换函数 linear_transform_increase=double_gray_pic*tan(pi/3); %当a<pi/4时,灰度压缩,a>pi/4时,灰度拉伸 figure('name','线性变换'); subplot(1,3,1);imshow(gray_pic);title('原灰度图'); subplot(1,3,2);imshow(im2uint8(linear_transform_reduce),[]);title('灰度压缩'); %im2double后的图像用im2uint8转换成uint8 subplot(1,3,3);imshow(im2uint8(linear_transform_increase),[]);title('灰度拉伸');
- 运行效果:
1.3 对数变换
- 对数函数
- Matlab代码块:
%-------------------------对数变换(Matlab代码)--------------------------- clc; clear; close all; gray_pic=imread('log_picture.bmp'); %读取灰度图像 double_gray_pic=im2double(gray_pic); %进行log运算得把uint8转换成double型 log_transform=3*log(1+double_gray_pic); %对数变换g(x,y)=clog[1+f(x,y)],c=3 figure('name','对数变换'); subplot(1,2,1);imshow(gray_pic,[]);title('原灰度图'); subplot(1,2,2);imshow(im2uint8(log_transform),[]);title('对数变换'); %im2double后的图像用im2uint8转换成uint8
- 运行效果:
2、对选定的灰度图像进行直方图均衡化处理,并显示处理前后的直方图。
2.1 直方图均衡化
- Matlab代码块:
%-------------------------直方图均衡化(Matlab代码)----------------------- clc; %清空控制台 clear; %清空工作区 close all; %关闭已打开的figure图像窗口 color_pic=imread('lena512color.bmp'); %读取彩色图像 gray_pic=rgb2gray(color_pic); %将彩色图转换成灰度图 histogram_equalization=histeq(gray_pic); %调用histeq函数进行直方图均衡化 figure('name','直方图均衡化'); subplot(2,2,1);imshow(gray_pic,[]);title('原灰度图'); subplot(2,2,2);imshow(histogram_equalization,[]);title('直方图均衡化后灰度图'); subplot(2,2,3);imhist(gray_pic,64);title('原直方图'); %直方图划分成64个长度为4的灰度空间,方便查看效果 subplot(2,2,4);imhist(histogram_equalization,64);title('直方图均衡化'); %直方图划分成64个长度为4的灰度空间,方便查看效果
- 运行效果:
3、分别在两幅灰度图像中加入一定量的高斯噪声和椒盐噪声,噪声强度自定。然后分别采用3x3的均值滤波和3x3中值滤波对噪声进行处理,显示结果图像,并计算出两种处理方法的峰值信噪比(PSNR)。
3.1 添加高斯噪声和椒盐噪声
- Matlab代码块:
%------------------------------添加噪声(Matlab代码)----------------------------- clc; %清空控制台 clear; %清空工作区 close all; %关闭已打开的figure图像窗口 color_pic=imread('lena512color.bmp'); %读取彩色图像 gray_pic=rgb2gray(color_pic); %将彩色图转换成灰度图 double_gray_pic=im2double(gray_pic); %将uint8转成im2double型便于后期计算 Gaussian_noise=imnoise(double_gray_pic,'gaussian',0,0.01); %给灰度图添加均值为0,方差为0.01的高斯噪声 Salt_pepper_noise=imnoise(double_gray_pic,'salt & pepper',0.05); %给灰度图添加噪声密度为0.05的椒盐噪声 figure('name','加噪'); subplot(1,3,1);imshow(double_gray_pic,[]);title('原灰度图'); subplot(1,3,2);imshow(Gaussian_noise,[]);title('加高斯噪声'); subplot(1,3,3);imshow(Salt_pepper_noise,[]);title('加椒盐噪声');
- 运行效果:
3.2 峰值信噪比PSNR
-
原理公式:
-
Matlab代码块:
%------------------------matlab新建函数PSNR------------------------ function cal_PSNR = PSNR(img1,img2) [width,height]=size(img1); double_img1=im2double(img1); %计算图像峰值信噪比,需将2张图像从uint8型转成im2double型 double_img2=im2double(img2); matrix_subtraction=double_img1-double_img2; MSE=sum(sum(matrix_subtraction.^2))/(width*height); cal_PSNR=10*log10(255^2/MSE); end
3.3 对高斯噪声进行滤波并计算PSNR
- Matlab代码块:
%-----------------------------对高斯噪声进行滤波并计算PSNR (Matlab代码)------------------------------- gaussian_mean_filter=filter2(fspecial('average',3),Gaussian_noise); %均值滤波 gau_mean_filter_snr=PSNR(double_gray_pic,gaussian_mean_filter); %均值滤波后的峰值信噪比 gaussian_median_filter=medfilt2(Gaussian_noise,[3,3]); %中值滤波 gau_median_filter_snr=PSNR(double_gray_pic,gaussian_median_filter); %中值滤波后的峰值信噪比 figure('name','对高斯噪声进行滤波'); subplot(1,2,1);imshow(gaussian_mean_filter,[]);title(['均值滤波,PSNR:',num2str(gau_mean_filter_snr),'dB']); subplot(1,2,2);imshow(gaussian_median_filter,[]);title(['中值滤波,PSNR:',num2str(gau_median_filter_snr),'dB']);
- 运行效果:
3.4 对椒盐噪声进行滤波并计算PSNR
- Matlab代码块:
%-----------------------------对椒盐噪声进行滤波并计算PSNR (Matlab代码)------------------------------- salt_mean_filter=filter2(fspecial('average',3),Salt_pepper_noise); %均值滤波 salt_mean_filter_snr=PSNR(double_gray_pic,salt_mean_filter); %均值滤波后的峰值信噪比 salt_median_filter=medfilt2(Salt_pepper_noise,[3,3]); %中值滤波 salt_median_filter_snr=PSNR(double_gray_pic,salt_median_filter); %中值滤波后的峰值信噪比 figure('name','对椒盐噪声进行滤波'); subplot(1,2,1);imshow(salt_mean_filter,[]);title(['均值滤波,PSNR:',num2str(salt_mean_filter_snr),'dB']); subplot(1,2,2);imshow(salt_median_filter,[]);title(['中值滤波,PSNR:',num2str(salt_median_filter_snr),'dB']);
- 运行效果:
4、对选定的灰度图像进行锐化处理:先对原图像进行3*3均值滤波使其模糊,再分别通过Roberts算子、Sobel算子、拉普拉斯算子对其进行边缘增强处理,显示结果图像并对比各方法的结果
4.1 均值滤波
- Matlab代码块:
%-----------------------------------3*3均值滤波模糊图像(Matlab代码)---------------------------- clc; %清空控制台 clear; %清空工作区 close all; %关闭已打开的figure图像窗口 color_pic=imread('lena512color.bmp'); %读取彩色图像 gray_pic=rgb2gray(color_pic); %将彩色图转换成灰度图 double_gray_pic=im2double(gray_pic); %将uint8转成im2double型便于后期计算 mean_filter=filter2(fspecial('average',3),double_gray_pic); %均值滤波 [width,height]=size(mean_filter); figure('name','3*3均值滤波'); subplot(1,2,1);imshow(double_gray_pic,[]);title('原灰度图'); subplot(1,2,2);imshow(mean_filter,[]);title('3*3均值滤波');
- 运行效果:
4.2 Roberts算子边缘增强
- 原理公式
- Matlab代码块:
% ------------------------------Roberts算子边缘增强(Matlab)-------------------------------- roberts_img = zeros(width,height); %预先分配内存空间,提高运行速率 for i=1:width-1 for j=1:height-1 roberts_img(i,j)=abs(mean_filter(i+1,j)-mean_filter(i,j+1))+abs(mean_filter(i,j)-mean_filter(i+1,j+1)); end end figure('name','roberts算子'); subplot(2,2,1);imshow(double_gray_pic,[]);title('原灰度图'); subplot(2,2,2);imshow(mean_filter,[]);title('3x3均值滤波'); subplot(2,2,3);imshow(im2uint8(roberts_img),[]);title('roberts算子的图像'); subplot(2,2,4);imshow(im2uint8(mean_filter+roberts_img),[]);title('roberts算子锐化图像');
- 运行效果:
4.3 Sobel算子边缘增强
-
原理公式
-
Matlab代码块:
% ------------------------------Sobel算子边缘增强(Matlab代码)-------------------------------- sobel_img=zeros(width,height); %预先分配内存空间,提高运行速率 sobel_x=zeros(width,height); %预先分配内存空间,提高运行速率 sobel_y=zeros(width,height); %预先分配内存空间,提高运行速率 for i=2:width-1 for j=2:height-1 sobel_y(i,j)=abs(mean_filter(i-1,j+1)+2*mean_filter(i,j+1)+mean_filter(i+1,j+1)-mean_filter(i-1,j-1)-2*mean_filter(i,j-1)-mean_filter(i+1,j-1)); sobel_x(i,j)=abs(mean_filter(i+1,j+1)+2*mean_filter(i+1,j)+mean_filter(i+1,j-1)-mean_filter(i-1,j+1)-2*mean_filter(i-1,j)-mean_filter(i-1,j-1)); sobel_img(i,j)=0.3*sobel_x(i,j)+0.3*sobel_y(i,j); end end figure('name','sobel算子'); subplot(2,2,1);imshow(double_gray_pic,[]);title('原灰度图'); subplot(2,2,2);imshow(mean_filter,[]);title('3x3均值滤波'); subplot(2,2,3);imshow(im2uint8(sobel_img),[]);title('sobel算子的图像'); subplot(2,2,4);imshow(im2uint8(mean_filter+sobel_img),[]);title('sobel算子锐化图像');
- 运行效果:
4.4 拉普拉斯算子边缘增强
- 原理公式
- Matlab代码块:
% ------------------------------Laplace算子边缘增强(Matlab代码)---------------------------------- laplace_img = zeros(width,height); %预先分配内存空间,提高运行速率 for i=2:width-1 for j=2:height-1 laplace_img(i,j)=mean_filter(i+1,j)+mean_filter(i-1,j)+mean_filter(i,j+1)+mean_filter(i,j-1)-4*mean_filter(i,j); end end figure('name','laplace算子'); subplot(2,2,1);imshow(double_gray_pic,[]);title('原灰度图'); subplot(2,2,2);imshow(mean_filter,[]);title('3x3均值滤波'); subplot(2,2,3);imshow(im2uint8(laplace_img),[]);title('laplace算子的图像'); subplot(2,2,4);imshow(im2uint8(mean_filter-laplace_img),[]);title('laplace算子锐化图像'); %由于采用的拉普拉斯算子中心是-4为负数,所以最后图像锐化是将两幅图相减
- 运行效果:
5、对选定的灰度图像进行巴特沃斯高通滤波处理:要求设定多种不同(高、中、低)的截止频率进行滤波,显示其经滤波后的空域图像
- 基本原理:
- Matlab代码块:
%************************5、对选定的灰度图像进行巴特沃斯高通滤波处理:要求设定多种不同(高、中、低)的截止频率进行滤波,显示其经滤波后的空域图像************************** clc; %清空控制台 clear; %清空工作区 close all; %关闭已打开的figure图像窗口 color_pic=imread('lena512color.bmp'); %读取彩色图像 gray_pic=rgb2gray(color_pic); %将彩色图转换成灰度图 double_gray_pic=im2double(gray_pic); %将uint8转成im2double型便于后期计算 [width,height]=size(double_gray_pic); mid_w=width/2; %图像中心点横坐标 mid_h=height/2; %图像中心点纵坐标 fourier_pic=fft2(double_gray_pic); %对灰度图进行傅里叶变换 fourier_shift=fftshift(fourier_pic); %将频谱图中零频率成分移动至频谱图中心 level=2; %二阶巴特沃兹 end_radius=[5,30,83]; %设置截止频率 result1=zeros(width,height); %预先分配内存空间,提高运行速率 result2=zeros(width,height); %预先分配内存空间,提高运行速率 result3=zeros(width,height); %预先分配内存空间,提高运行速率 for i=1:width for j=1:height distance=sqrt((i-mid_w)^2+(j-mid_h)^2); %计算点(x,y)到中心点的距离 h1=1/(1+(end_radius(1)/distance)^(2*level)); %计算巴特沃斯滤波器 h2=1/(1+(end_radius(2)/distance)^(2*level)); h3=1/(1+(end_radius(3)/distance)^(2*level)); result1(i,j)=fourier_shift(i,j)*h1; %用滤波器乘以主函数 result2(i,j)=fourier_shift(i,j)*h2; result3(i,j)=fourier_shift(i,j)*h3; end end output1=im2uint8(real(ifft2(ifftshift(result1)))); %最终输出要记得频谱搬移回去 output2=im2uint8(real(ifft2(ifftshift(result2)))); output3=im2uint8(real(ifft2(ifftshift(result3)))); figure('name','巴特沃兹高通滤波器'); subplot(2,2,1);imshow(double_gray_pic);title('原灰度图'); subplot(2,2,2);imshow(output1,[]);title(['巴特沃兹高通滤波 D0=',num2str(end_radius(1))]); subplot(2,2,3);imshow(output2,[]);title(['巴特沃兹高通滤波 D0=',num2str(end_radius(2))]); subplot(2,2,4);imshow(output3,[]);title(['巴特沃兹高通滤波 D0=',num2str(end_radius(3))]);
- 运行效果:
6、对选定的灰度图像进行理想低通滤波处理:要求设定多种不同(高、中、低)的截止频率进行滤波,显示其经滤波后的空域图像。
- 基本原理:
- Matlab代码块:
%************************6、对选定的灰度图像进行理想低通滤波处理:要求设定多种不同(高、中、低)的截止频率进行滤波,显示其经滤波后的空域图像************************** clc; %清空控制台 clear; %清空工作区 close all; %关闭已打开的figure图像窗口 color_pic=imread('lena512color.bmp'); %读取彩色图像 gray_pic=rgb2gray(color_pic); %将彩色图转换成灰度图 double_gray_pic=im2double(gray_pic); %将uint8转成im2double型便于后期计算 [width,height]=size(double_gray_pic); mid_w=width/2; %图像中心点横坐标 mid_h=height/2; %图像中心点纵坐标 fourier_pic=fft2(double_gray_pic); %对灰度图进行傅里叶变换 fourier_shift=fftshift(fourier_pic); %将频谱图中零频率成分移动至频谱图中心 end_radius=[5,30,83]; %设置截止频率 Result=zeros(width,height); %预先分配内存空间,提高运行速率 figure('name','理想低通滤波器'); subplot(2,2,1);imshow(double_gray_pic,[]);title('原灰度图'); for k=1:3 Result=fourier_shift; for i=1:width for j=1:height distance=sqrt((i-mid_w)^2+(j-mid_h)^2); %计算点(x,y)到中心点的距离 if distance>end_radius(k) %如果距离大于截止频率,则滤除分量,直接置0 Result(i,j)=0; end end end output=im2uint8(real(ifft2(ifftshift(Result)))); %最终输出要记得频谱搬移回去 subplot(2,2,k+1);imshow(output,[]);title(['理想低通滤波器 D0=',num2str(end_radius(k))]); end
- 运行效果:
7、对选定的一幅RGB彩色图像(BMP格式),分别显示该图的R/G/B单色图像,绘制R/G/B单色图像的直方图;将RGB彩色模式转换为HIS模式,再显示该图的H/I/S三个分量的图像。
- RGB转HSI公式:
- Matlab代码块:
%************************7、对选定的一幅RGB彩色图像(BMP格式),分别显示该图的R/G/B单色图像,绘制R/G/B单色图像的直方图;将RGB彩色模式转换为HIS模式,再显示该图的H/I/S三个分量的图像************************** clc; %清空控制台 clear; %清空工作区 close all; %关闭已打开的figure图像窗口 color_pic=imread('lena512color.bmp'); %读取彩色图像 double_color_pic=im2double(color_pic); %将uint8转成im2double型便于后期计算 %----------------------------分别提取R/G/B三个通道图像--------------------------- R=double_color_pic(:,:,1); %R,G,B二维用于计算 G=double_color_pic(:,:,2); B=double_color_pic(:,:,3); figure('name','提取R/G/B图像,二维灰度图') subplot(2,2,1);imshow(double_color_pic,[]);title('原彩色图像'); subplot(2,2,2);imshow(R,[]);title('R'); subplot(2,2,3);imshow(G,[]);title('G'); subplot(2,2,4);imshow(B,[]);title('B'); zero=zeros(512,512); %此彩色图单层为512*512,生成512*512的0矩阵,用于R1,G1,B1的三维构成,显示有颜色的通道 R1=cat(3,R,zero,zero); %R1三维 三维能显示红绿蓝背景色 G1=cat(3,zero,G,zero); %G1三维 B1=cat(3,zero,zero,B); %B1三维 figure('name','提取R/G/B图像,三维彩色图'); subplot(2,2,1);imshow(double_color_pic,[]);title('原彩色图像'); subplot(2,2,2);imshow(R1,[]);title('R'); subplot(2,2,3);imshow(G1,[]);title('G'); subplot(2,2,4);imshow(B1,[]);title('B'); figure('name','R/G/B单色图像直方图'); subplot(3,2,1);imshow(R1,[]);title('R'); subplot(3,2,2);imhist(R,128);title('R直方图'); subplot(3,2,3);imshow(G1,[]);title('G'); subplot(3,2,4);imhist(G,128);title('G直方图'); subplot(3,2,5);imshow(B1,[]);title('B'); subplot(3,2,6);imhist(B,128);title('B直方图'); %----------------------------RGB转HSI------------------------------ num=0.5*((R-G)+(R-B)); den=sqrt((R-G).^2+(R-B).*(G-B)); theta=acos(num./(den+eps)); %eps=2.2204e-16 防止分母为0 H=theta; H(B>G)=2*pi-H(B>G); H=H/(2*pi); %归一化处理 num=min(min(R,G),B); den=R+G+B; den(den==0)=eps; %eps=2.2204e-16 防止分母为0 S=1-3*num./den; H(S==0)=0; %完全不饱和的颜色根本没有色调 即饱和度为0时色调无定义置0 I=(R+G+B)/3; HSI=cat(3,H,S,I); %合并三个图层 figure('name','HSI图像'); subplot(2,2,1);imshow(HSI,[]);title('HSI图像'); subplot(2,2,2);imshow(H,[]);title('H分量,色调'); subplot(2,2,3);imshow(S,[]);title('S分量,饱和度'); subplot(2,2,4);imshow(I,[]);title('I分量,亮度');
- 运行效果:
8、对一幅彩色RGB图像,采用对每一彩色分量进行拉普拉斯算子滤波,完成图像锐化处理。
- 原理公式
- Matlab代码块:
%************************8、对一幅彩色RGB图像,采用对每一彩色分量进行拉普拉斯算子滤波,完成图像锐化处理************************** clc; %清空控制台 clear; %清空工作区 close all; %关闭已打开的figure图像窗口 color_pic=imread('lena512color.bmp'); %读取彩色图像 double_color_pic=im2double(color_pic); %将uint8转成im2double型便于后期计算 %-----先提取三个图层------ R=double_color_pic(:,:,1); %提取R图层 G=double_color_pic(:,:,2); %提取G图层 B=double_color_pic(:,:,3); %提取B图层 [width,height]=size(R); laplace_imgR = zeros(width,height); %预先分配内存空间,提高运行速率 laplace_imgG = zeros(width,height); %预先分配内存空间,提高运行速率 laplace_imgB = zeros(width,height); %预先分配内存空间,提高运行速率 %--------分别对R/G/B图层进行拉普拉斯算子滤波------- for i=2:width-1 for j=2:height-1 laplace_imgR(i,j)=R(i+1,j)+R(i-1,j)+R(i,j+1)+R(i,j-1)-4*R(i,j); laplace_imgG(i,j)=G(i+1,j)+G(i-1,j)+G(i,j+1)+G(i,j-1)-4*G(i,j); laplace_imgB(i,j)=B(i+1,j)+B(i-1,j)+B(i,j+1)+B(i,j-1)-4*B(i,j); end end output=cat(3,laplace_imgR,laplace_imgG,laplace_imgB); %合并三个经拉普拉斯算子滤波后的图层 figure('name','RGB拉普拉斯算子锐化'); subplot(2,2,1);imshow(laplace_imgR,[]);title('R分量拉普拉斯滤波'); subplot(2,2,2);imshow(laplace_imgG,[]);title('G分量拉普拉斯滤波'); subplot(2,2,3);imshow(laplace_imgB,[]);title('B分量拉普拉斯滤波'); subplot(2,2,4);imshow(output,[]);title('合成图像拉普拉斯滤波'); figure('name','三通道锐化后的图像'); subplot(1,2,1);imshow(color_pic,[]);title('原彩色图'); subplot(1,2,2);imshow(im2uint8(double_color_pic-output));title('拉普拉斯锐化');
- 运行效果:
-
Matalb-邻域平均法、均值滤波法、中值滤波法对图像进行平滑去噪
2020-04-24 11:19:05中值滤波6. Matlab代码实现 1. 空间滤波增强 空间滤波是通过在图像空间借助模板进行邻域操作完成对图像的滤波操作,包括线性的和非线性的。 空域滤波的主要功能: 平滑:低通滤波器: 目的: 模糊化:在提取较大... -
MATLAB源码-MATLAB源码.rar
2019-08-13 07:29:39P0306:采用二维中值滤波函数medfilt2对受椒盐噪声干扰的图像滤波 P0307:采用MATLAB中的函数filter2对受噪声干扰的图像进行均值滤波 P0308:图像的自适应魏纳滤波 P0309:运用5种不同的梯度增强法进行图像锐化 ... -
matlab图像处理
2009-06-06 10:08:11基于matlab和vc++的源代码肯定可以调试通过 采用比较简单的编程手段 共能有:直方均衡 掩膜 中值滤波 梯度法 锐化 -
哈工大深研院数字图像处理第一次大作业:不调用Matlab现有库函数实现图像增强
2016-04-06 14:35:14不调用自带函数,实现Matlab下的图像灰度直方图均衡化,实现Matlab模板中值滤波,实现利用Matlab高斯高通滤波器进行图像锐化处理。 -
MATLAB数字图像处理.zip
2020-04-07 17:21:26Matlab环境下的几个数字图像处理实验,包含图像灰度变换、直方图均衡化、直方图匹配、邻域平均、局域增强、中值滤波、图像的锐化等 -
matlab图像
2013-02-01 14:47:42P0306:采用二维中值滤波函数medfilt2对受椒盐噪声干扰的图像滤波 P0307:采用MATLAB中的函数filter2对受噪声干扰的图像进行均值滤波 P0308:图像的自适应魏纳滤波 P0309:运用5种不同的梯度增强法进行图像锐化 ... -
MATLAB日记
2019-08-25 15:27:55几种滤波对比 1平滑滤波: 优点:算法简单,速度快 缺点:模糊图像 2中值滤波: 优点:在一定条件下,可以克服线性滤波器所带来的图像细节模糊,而且...优点能够减少低频增强高频,从而减少关照变化并锐化边缘细节 ...