本文整理汇总了Python中skimage.filters.gaussian_filter方法的典型用法代码示例。如果您正苦于以下问题:Python filters.gaussian_filter方法的具体用法?Python filters.gaussian_filter怎么用?Python filters.gaussian_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skimage.filters
的用法示例。
在下文中一共展示了filters.gaussian_filter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unsharp
# 需要导入模块: from skimage import filters [as 别名]
# 或者: from skimage.filters import gaussian_filter [as 别名]
def unsharp(img):
''' unsharp(img)
apply unsharp mask to the image
img: original image array
Return: image after unsharp masking, array like'''
def unsharp2d(img):
if len(img.shape) == 2:
blur = gaussian_filter(img, 50)
blur = -0.1*blur
return blur + img
else:
raise Exception('The image size is not recognized.')
if len(img.shape) == 3 and img.shape[2] == 3:
img[:, :, 0] = unsharp2d(img[:, :, 0])
img[:, :, 1] = unsharp2d(img[:, :, 1])
img[:, :, 2] = unsharp2d(img[:, :, 2])
elif len(img.shape) == 2:
img = unsharp2d(img)
else:
raise Exception('The image size is not recognized.')
return img
示例2: _resize
# 需要导入模块: from skimage import filters [as 别名]
# 或者: from skimage.filters import gaussian_filter [as 别名]
def _resize(args):
img, rescale_size, bbox = args
img = img[bbox[0]:bbox[1], bbox[2]:bbox[3]]
# Smooth image before resize to avoid moire patterns
scale = img.shape[0] / float(rescale_size)
sigma = np.sqrt(scale) / 2.0
img = filters.gaussian_filter(img, sigma=sigma, multichannel=True)
img = transform.resize(img, (rescale_size, rescale_size, 3), order=3)
img = (img*255).astype(np.uint8)
return img
示例3: get_blend_map
# 需要导入模块: from skimage import filters [as 别名]
# 或者: from skimage.filters import gaussian_filter [as 别名]
def get_blend_map(img, att_map, blur=True, overlap=True):
att_map -= att_map.min()
if att_map.max() > 0:
att_map /= att_map.max()
att_map = transform.resize(att_map, (img.shape[:2]), order = 3, mode='nearest')
if blur:
att_map = filters.gaussian_filter(att_map, 0.02*max(img.shape[:2]))
att_map -= att_map.min()
att_map /= att_map.max()
cmap = plt.get_cmap('jet')
att_map_v = cmap(att_map)
att_map_v = np.delete(att_map_v, 3, 2)
if overlap:
att_map = 1*(1-att_map**0.7).reshape(att_map.shape + (1,))*img + (att_map**0.7).reshape(att_map.shape+(1,)) * att_map_v
return att_map
示例4: difference_of_gaussian
# 需要导入模块: from skimage import filters [as 别名]
# 或者: from skimage.filters import gaussian_filter [as 别名]
def difference_of_gaussian(self, imin, bigsize=30.0, smallsize=3.0):
g1 = filters.gaussian_filter(imin, bigsize)
g2 = filters.gaussian_filter(imin, smallsize)
diff = 255*(g1 - g2)
diff[diff < 0] = 0.0
diff[diff > 255.0] = 255.0
diff = diff.astype(np.uint8)
return diff
示例5: getImage
# 需要导入模块: from skimage import filters [as 别名]
# 或者: from skimage.filters import gaussian_filter [as 别名]
def getImage(self, params):
sigma = float(params['sigma'])
r = float(params['red'])
g = float(params['green'])
b = float(params['blue'])
image = data.coffee()
new_image = filters.gaussian_filter(image, sigma=sigma, multichannel=True)
new_image[:, :, 0] = r * new_image[:, :, 0]
new_image[:, :, 1] = g * new_image[:, :, 1]
new_image[:, :, 2] = b * new_image[:, :, 2]
return new_image