def N(image):
"""
Normalization parameter as per Itti et al. (1998).
returns a normalized feature map image.
"""
M = 8. # an arbitrary global maximum to which the image is scaled.
# (When saving saliency maps as images, pixel values may become
# too large or too small for the chosen image format depending
# on this constant)
image = cv2.convertScaleAbs(image, alpha=M/image.max(), beta=0.)
w,h = image.shape
maxima = maximum_filter(image, size=(w/10,h/1))
maxima = (image == maxima)
mnum = maxima.sum()
logger.debug("Found %d local maxima.", mnum)
maxima = numpy.multiply(maxima, image)
mbar = float(maxima.sum()) / mnum
logger.debug("Average of local maxima: %f. Global maximum: %f", mbar, M)
return image * (M-mbar)**2
评论列表
文章目录