反锐化掩膜_光电图像处理 | 空域锐化滤波
生活随笔
收集整理的這篇文章主要介紹了
反锐化掩膜_光电图像处理 | 空域锐化滤波
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
銳化濾波
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);endRESULT
神奇特效...
到此為止,把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
反銳化掩膜
Unsharp?masking
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 空域結束
下次頻域見。
總結
以上是生活随笔為你收集整理的反锐化掩膜_光电图像处理 | 空域锐化滤波的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为全屋智能 5.0 发布:业界首创 P
- 下一篇: Redmi Watch 4 搭载小米澎湃