MATLAB Image Sharpening - Gaussian High Pass Filter using (1- Gaussian Low Pass Filter)

筅森魡賤 提交于 2019-12-01 11:53:54

问题


I am trying to sharpen an image by designing a Gaussian High-Pass Filter. I would like to do this using the fact that the high-pass filter is equivalent to the identity matrix minus the low-pass filter, so I did the following:

image= imread('Question3_Data-Cats.jpg'); % read image

H = 1 - fspecial('gaussian' ,[5 5],2); % create unsharp mask
sharpened = imfilter(image,H);  % create a sharpened version of the image using that mask

imshow([image sharpened]); %showing input & output images

I did not get a sharpened image. Instead, I got a white image with some colors on a small region of the image. Can someone help? Thank you.


回答1:


Try this:

H = padarray(2,[2 2]) - fspecial('gaussian' ,[5 5],2); % create unsharp mask

1 is a scalar. You need a 5x5 array with one in the center. Furthermore, the filter elements must sum to one if you want to conserve brightness, so you need to double the central value to counter the amount you are subtracting.




回答2:


Let g be the gaussian kernel and f be the image. Then f * g (convolution) gives the blurred version of the image. That means low-passed version of the image.

Then consider . It means image - lowpass image. That gives the high-passed version of the image. It contains only image details. The details are in white on the black background. I think that is the image you are getting right now.

After you have extracted the image details from the image, you have to add them back to the image to get a sharpened image.

That means you can get the sharpened image by convolution of 2e - g with your image(This is the unsharp mask).

You can get 2e from matlab using padarray(2,[2 2]) and g using fspecial('gaussian' ,[5 5],2).

H = padarray(2,[2 2]) - fspecial('gaussian' ,[5 5],2); %create unsharp mask

Sometimes, you will need to control the brightness of the image details. You can do that by

sharpen image = image + alpha(image details)




回答3:


I= imread('peppers.png'); % read image
H = padarray(2,[2 2]) - fspecial('gaussian' ,[5 5],2); % create unsharp mask % create unsharp mask
figure,imshow(I);
K = imfilter(I,H);  % create a sharpened version of the image using that mask
figure,imshow(K); %showing input & output images


来源:https://stackoverflow.com/questions/15854228/matlab-image-sharpening-gaussian-high-pass-filter-using-1-gaussian-low-pass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!