彩色圖像的銳化處理

彩色圖像的銳化處理

1、使用拉普拉斯濾波圖像增強

(1)代碼

%彩色圖像的銳化處理
clc;
clear all;
close all;
f=imread('0.jpg'); 	%加載原圖像
figure;imshow(f);title('原始圖像');
fb=tofloat(f);  	%將圖像轉化爲浮點型
lapmask=[1 1 1;1 -8 1;1 1 1]; 	%拉普拉斯濾波模板
fen=fb-imfilter(fb,lapmask,'replicate');
figure;imshow(fen);title('增強後');

(2)函數tofloat定義

function [out,revertclass] = tofloat(inputimage)
%Copy the book of Gonzales
identify = @(x) x;
tosingle = @im2single;
table = {'uint8',tosingle,@im2uint8 
         'uint16',tosingle,@im2uint16 
         'logical',tosingle,@logical
         'double',identify,identify
         'single',identify,identify};
classIndex = find(strcmp(class(inputimage),table(:,1)));
if isempty(classIndex)
    error('不支持的圖像類型');
end
out = table{classIndex,2}(inputimage);
revertclass = table{classIndex,3};

2、運行結果


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章