实例:彩色图像的锐化
clc;
clear;
%读取经典图像lena.jpg
A = imread('lena.jpg');
figure,imshow(A),title('原图像');
%提取三个通道的像素值
R_A = A(:,:,1);
G_A = A(:,:,2);
B_A = A(:,:,3);
figure
subplot(1,3,1),imshow(R_A),title('R通道');
subplot(1,3,2),imshow(G_A),title('G通道');
subplot(1,3,3),imshow(B_A),title('B通道');
%定义锐化算子
h1 = fspecial('sobel');
h2 = fspecial('prewitt');
%R通道锐化
R_h1 = imfilter(R_A, h1);
R_h2 = imfilter(R_A, h2);
figure,
subplot(1,2,1),imshow(R_h1),title('Sobel R通道锐化');
subplot(1,2,2),imshow(R_h2),title('Prewitt R通道锐化');
%G通道锐化
G_h1 = imfilter(G_A, h1);
G_h2 = imfilter(G_A, h2);
figure,
subplot(1,2,1),imshow(G_h1),title('Sobel G通道锐化');
subplot(1,2,2),imshow(G_h2),title('Prewitt G通道锐化');
%B通道锐化
B_h1 = imfilter(B_A, h1);
B_h2 = imfilt