98 lines
2.2 KiB
Mathematica
98 lines
2.2 KiB
Mathematica
|
% 读取图片
|
||
|
image = imread('EXP_3_4/test.jpg');
|
||
|
image_airport = imread('EXP_3_4/airport.jpg');
|
||
|
|
||
|
% 设置核的值
|
||
|
h1 = [1 1 1; 1 1 1; 1 1 1] / 9;
|
||
|
h2 = [1 2 1; 2 4 2; 1 2 1] / 16;
|
||
|
h3 = [-1 -1 -1; -1 9 -1; -1 -1 -1];
|
||
|
h4 = [0 -1 0; -1 5 -1; 0 -1 0];
|
||
|
h5 = [-1 -1 -1; -1 10 -1; -1 -1 -1];
|
||
|
h6 = [-1 -1 -1; -1 8 -1; -1 -1 -1];
|
||
|
h7 = [1 1 1; 1 -8 1; 1 1 1];
|
||
|
h8 = [-1 0 1; -2 0 2; -1 0 1];
|
||
|
h9 = [-1 -2 -1; 0 0 0; 1 2 1];
|
||
|
h10 = [1 -1];
|
||
|
h11 = [1 0 -1];
|
||
|
|
||
|
% 处理图像
|
||
|
image_h1 = imfilter(image, h1);
|
||
|
image_h2 = imfilter(image, h2);
|
||
|
image_h3 = imfilter(image, h3);
|
||
|
image_h4 = imfilter(image, h4);
|
||
|
image_h5 = imfilter(image, h5);
|
||
|
image_h6 = imfilter(image, h6);
|
||
|
image_h7 = imfilter(image_airport, h7);
|
||
|
image_h8 = imfilter(image_airport, h8);
|
||
|
image_h9 = imfilter(image_airport, h9);
|
||
|
image_h10 = imfilter(image_airport, h10);
|
||
|
image_h11 = imfilter(image_airport, h11);
|
||
|
|
||
|
image_add = abs(image_h8) + abs(image_h9);
|
||
|
|
||
|
% 展示照片
|
||
|
figure;
|
||
|
subplot(1,3,1);
|
||
|
imshow(image);
|
||
|
title('Original Image'); % 原图
|
||
|
subplot(1,3,2);
|
||
|
imshow(image_h1);
|
||
|
title('Mean Smoothing'); % 均值平滑
|
||
|
subplot(1,3,3);
|
||
|
imshow(image_h2);
|
||
|
title('Gaussian Smoothing'); % 高斯平滑
|
||
|
|
||
|
figure;
|
||
|
subplot(1,3,1);
|
||
|
imshow(image);
|
||
|
title('Original Image'); % 原图
|
||
|
subplot(1,3,2);
|
||
|
imshow(image_h3);
|
||
|
title('Sharpening one'); % 锐化一
|
||
|
subplot(1,3,3);
|
||
|
imshow(image_h4);
|
||
|
title('Sharpening two'); % 锐化二
|
||
|
|
||
|
figure;
|
||
|
subplot(1,3,1);
|
||
|
imshow(image);
|
||
|
title('Original Image'); % 原图
|
||
|
subplot(1,3,2);
|
||
|
imshow(image_h5);
|
||
|
title('Energy Enchancement'); % 能量增强
|
||
|
subplot(1,3,3);
|
||
|
imshow(image_h6);
|
||
|
title('Energy Weakening'); % 能量削弱
|
||
|
|
||
|
figure;
|
||
|
subplot(1,2,1);
|
||
|
imshow(image_airport);
|
||
|
title('Original Image'); % 原图
|
||
|
subplot(1,2,2);
|
||
|
imshow(image_h7);
|
||
|
title('Grayed Image'); % 灰度化图像
|
||
|
|
||
|
figure;
|
||
|
subplot(2,2,1);
|
||
|
imshow(image_airport);
|
||
|
title('Original Image'); % 原图
|
||
|
subplot(2,2,2);
|
||
|
imshow(image_h8);
|
||
|
title('Horizon'); % 水平
|
||
|
subplot(2,2,3);
|
||
|
imshow(image_h9);
|
||
|
title('Vertical'); % 垂直
|
||
|
subplot(2,2,4);
|
||
|
imshow(image_add);
|
||
|
title('Overlay'); % 叠加
|
||
|
|
||
|
figure;
|
||
|
subplot(1,3,1);
|
||
|
imshow(image_airport);
|
||
|
title('Original Image'); % 原图
|
||
|
subplot(1,3,2);
|
||
|
imshow(image_h10);
|
||
|
title('Easy Edge one'); % 简单边缘一
|
||
|
subplot(1,3,3);
|
||
|
imshow(image_h11);
|
||
|
title('Easy Edge two'); % 简单边缘二
|