def highPassFilter(matrix,sigma):
'''
This function computes a high and low pass filter. This can be used
to reduce the effect of lighting.
A low pass image is first computed by convolving the image with a
Gausian filter of radius sigma. Second, a high pass image is computed
by subtracting the low pass image from the original image. This means that
the original image can be reconstructed by adding a low pass image and a high
pass image.
@returns: high_pass_image
'''
is_image = False
if isinstance(matrix,pv.Image):
matrix = matrix.asMatrix2D()
is_image = True
matrix = matrix - ndi.gaussian_filter(matrix,sigma)
if is_image:
return pv.Image(matrix)
return matrix
评论列表
文章目录