Python unsharp mask

2019-03-16 09:45发布

I want to use unsharp mask on a 16 Bit Image. The Image has 640 x 480 Pixel and is saved in a numpy array. In the first Step i blur the Image withe a Gaussian filter (three different Methods). After this i create a Mask by subtract the blur Image form the Original. in The last step i add the Mask multiplied by wightfaktor to the Original Image. But it don´t really works.

Here is the Python code:

Gaussian1 = ndimage.filters.gaussian_filter(Image,sigma=10.0)
Gaussian2 = filters.gaussian_filter(Image,sigma=10.0)
Gaussian3 = cv2.GaussianBlur(Image,(9,9),sigmaX=10.0)

Mask1 = Image - Gaussian1
UnsharpImage = Image + (WightFaktor*Mask1)

May Someone help me?

1条回答
Lonely孤独者°
2楼-- · 2019-03-16 10:35

To get an unsharp image using OpenCV you need to use the addWeighted function as follows:

import cv2

image = cv2.imread("lenna.jpg")
gaussian_3 = cv2.GaussianBlur(image, (9,9), 10.0)
unsharp_image = cv2.addWeighted(image, 1.5, gaussian_3, -0.5, 0, image)
cv2.imwrite("lenna_unsharp.jpg", unsharp_image)

Giving the following kind of result:

enter image description here

查看更多
登录 后发表回答