Python非锐化掩码 [英] Python unsharp mask

查看:277
本文介绍了Python非锐化掩码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在16位图像上使用非锐化遮罩。
图像具有640 x 480像素,并保存在numpy数组中。在第一步中,我使用高斯滤波器(三种不同的方法)模糊图像。在此之后,我通过从原始图形中减去模糊图像来创建蒙版。在最后一步中,我将面具乘以wightfaktor添加到原始图像。但它确实没有用。



这是Python代码:

  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 =图像 - Gaussian1
UnsharpImage =图像+(WightFaktor * Mask1)

愿有人帮助我吗?

解决方案

使用<$ c $获取不清晰的图像c> OpenCV 您需要使用


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?

解决方案

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:

这篇关于Python非锐化掩码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆