使用拉普拉斯滤波器的图像锐化中的灰色图像

use*_*578 0 matlab image-processing matrix image-enhancement image-editing

我是Image Processing的新手.

现在,我正在研究拉普拉斯锐化方法.但有一件事我无法理解.我希望你能帮助我.

众所周知,当我们将拉普拉斯滤波后的图像添加到原始图像时,会出现锐化的图像.

但是在获得拉普拉斯滤波后的图像后,我的参考书将这个拉普拉斯滤波后的图像缩放以用于显示目的并获得灰色图像.并将这个灰色的一个添加到原始图像,最后得到一个锐化的图像.

我的问题是我怎么能得到这个灰色的图像.

这是我的代码:

image1=imread('hw1image1.tif');
m=[1 1 1; 1 -8 1; 1 1 1];
f1=imfilter(image1,m);
r=image1-f1;
subplot(1,3,1);
imshow(image1);
subplot(1,3,2);
imshow(f1);
subplot(1,3,3);
imshow(r);
Run Code Online (Sandbox Code Playgroud)

f1是拉普拉斯滤波图像.但是你们都知道它并不是灰色的.我怎么能得到这个灰色的?

编辑:

http://i.imgur.com/9qqXX.jpg(第1张原始图片,第2张灰色图片,第3张锐化图片)

谢谢您的帮助.

Sha*_*hai 5

尝试

imshow( f1, [] ); title('Laplacian filtered image');
Run Code Online (Sandbox Code Playgroud)

添加[]imshow应该缩放灰度图像,你应该看到你的目标是在灰色的结果.

编辑:

可能导致问题的另一件事是图像的数据类型.如果您的图像存储为uint8类型,则它不会具有负值(因为unsigned类型).

尝试:

img = im2double( image1 ); % convert image from uint to double
f1 = imfilter( img, m );
figure; imshow( f1 ); title( 'Laplacian filtered image' );
r = img - f1; % perform the image editing with double precision variables and NOT with unsigned ints.
r = im2uint( r ); % if you have to -cast only the final result to unsigned ints.
Run Code Online (Sandbox Code Playgroud)

作为一般原则,始终对浮点图像执行图像处理,并避免对无符号int图像进行操作.

如果您没有选择(硬件/内存限制)并且必须使用无符号整数图像执行操作 - 请记住,不会表示负值并且会裁剪大值.你的操作应该能够处理这些情况.