1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 反锐化掩膜_光电图像处理 | 空域锐化滤波

反锐化掩膜_光电图像处理 | 空域锐化滤波

时间:2023-12-05 09:39:44

相关推荐

反锐化掩膜_光电图像处理 | 空域锐化滤波

锐化滤波

Sharpen filter

clc;close all;I = imread('图片11.jpg');set(figure(1), 'name','不同梯度合成效果', 'numbertitle', 'off');subplot(221),imshow(I);title('原图');I = rgb2gray(I);%% Roberts operatorH1x = [0 0 0;0 -1 0;0 0 1]; H1y = [0 0 0;0 0 -1;0 1 0];J1x = imfilter(I,H1x);J1y = imfilter(I,H1y);%% Prewitt operatorH2x = [-1 0 1;-1 0 1;-1 0 1]; H2y = [-1 -1 -1;0 0 0;1 1 1];J2x = imfilter(I,H2x);J2y = imfilter(I,H2y);%% Sobel operatorH3x = [-1 0 1;-2 0 2;-1 0 1]; H3y = [-1 -2 -1;0 0 0;1 2 1];J3x = imfilter(I,H3x);J3y = imfilter(I,H3y);%% 梯度合成原则[M1,M2,M3]=Combining_rules(J1x,J1y);%% 幅度增强策略T = double(20);I = double(I);[m1, m2, m3, m4, m5] = Amplitude_enhancement_strategy(I,M1,T);%% 显示结果subplot(222),imshow(uint8(M1));title('合成的梯度直接取模长');subplot(223),imshow(uint8(M2));title('合成的梯度取绝对值之和');subplot(224),imshow(uint8(M3));title('合成的梯度取x方向和y方向最大值');set(figure(2), 'name','最终锐化效果', 'numbertitle', 'off');subplot(231),imshow(uint8(I));title('原图');subplot(232),imshow(uint8(m1));title('合成的梯度直接幅值显示');subplot(233),imshow(uint8(m2));title('合成的梯度背景保留');subplot(234),imshow(uint8(m3));title('合成的梯度背景保留,轮廓取单一灰度值');subplot(235),imshow(uint8(m4));title('合成的梯度轮廓保留,背景取单一灰度值');subplot(236),imshow(uint8(m5));title('合成的梯度轮廓/背景分别取单一灰度值');%% 函数定义function [M1,M2,M3]=Combining_rules(J1x,J1y) % 梯度合成原则JJJx = double(J1x);JJJy = double(J1y);M1 = 2 * sqrt((JJJx).^2 + (JJJy).^2); % 模长M2 = 2 * abs(JJJx) + abs(JJJy); % 绝对值之和M3 = 2 * max(abs(JJJx),abs(JJJy)); % 取最大值% 说明:2 * 完全是为了放大效果,原图像素值实在是太低了endfunction [m1, m2, m3, m4, m5] = Amplitude_enhancement_strategy(I,M1,T) % 幅度增强策略% 直接幅值显示m1 = M1;% 背景保留m2 = M1 .* (M1 >= T) + I .* (M1 < T);% 背景保留,轮廓取单一灰度值m3 = double(250) .* (M1 >= T) + I .* (M1 < T);% 轮廓保留,背景取单一灰度值m4 = M1 .* (M1 >= T) + double(200) .* (M1 < T);% 轮廓/背景分别取单一灰度值m5 = double(0) .* (M1 >= T) + double(255) .* (M1 < T);end

RESULT

神奇特效...

到此为止,把Roberts算子那个地方整明白了。

拉普拉斯算子

Laplace

%% 拉普拉斯算子锐化clc;close all;I = imread('图片12.jpg');set(figure(1), 'name','BY ZH', 'numbertitle', 'off');subplot(131),imshow(I);title('原图');% I = rgb2gray(I);H1 = [0 1 0;1 -4 1;0 1 0];H2 = [1 1 1;1 -8 1;1 1 1];I = im2double(I);J1 = imfilter(I,H1,'replicate');J2 = imfilter(I,H2,'replicate');subplot(132),imshow(I-J1);title('Laplacian processing 4')subplot(133),imshow(I-J2);title('Laplacian processing 8')

RESULT

空域高通滤波设计

Spatial high pass filtering design

While the high-pass filtering enhances the edge/contour, the noise may also be enhanced. As a result, the layers of the image will be lost and become rough.

clc;close all;I = imread('图片12.jpg');set(figure(1), 'name','BY ZH', 'numbertitle', 'off');subplot(121),imshow(I);title('原图');H1 = [-1 -1 -1 -1 -1;-1 1 1 1 -1;-1 1 8 1 -1;-1 1 1 1 -1;-1 -1 -1 -1 -1];I = rgb2gray(I);I = im2double(I);J1 = imfilter(I,H1,'replicate');subplot(122),imshow(J1),title('2')

RESULT

反锐化掩膜

Unsharpmasking

clc;close all;I = imread('图片1.png');set(figure(1), 'name','BY ZH', 'numbertitle', 'off');subplot(221),imshow(I);title('原图');I = rgb2gray(I);J = ordfilt2(I,1,ones(3,3));subplot(222),imshow(J),title('最小值滤波效果')subplot(223),imshow(I-J),title('反锐化模')subplot(224),imshow(I-J+I),title('锐化效果')

RESULT

so 空域结束

下次频域见。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。