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

后端 未结 3 795
醉酒成梦
醉酒成梦 2021-01-16 11:16

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 matr

相关标签:
3条回答
  • 2021-01-16 11:54

    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.

    0 讨论(0)
  • 2021-01-16 11:56
    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
    
    0 讨论(0)
  • 2021-01-16 12:05

    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)

    0 讨论(0)
提交回复
热议问题