def get_heatmap(self, type='raw'): """ Returns heatmap calculated from saliency map of image passed to SightSpotDetector constructor. Parameters ---------- type : 'raw' or 'precise' Specifies whenever segmentation will be used to improve saliency map (slower). Returns ------- out : PIL.Image Heatmap. """ if type == 'raw': if self._raw_heatmap == None: saliency_map = self._get_saliency_map(type) self._raw_heatmap = SightSpotUtil.eval_heatmap(saliency_map) return self._raw_heatmap.copy() if type == 'precise': if self._precise_heatmap == None: fusion_map = self._get_saliency_map(type) self._precise_heatmap = SightSpotUtil.eval_heatmap(fusion_map) return self._precise_heatmap.copy() raise Exception('Unknown argument value type = "' + str(type) + '"')
__author__ = 'Igor Ryabtsov aka Tinnulion' __copyright__ = 'Copyright (c) 2014' __license__ = 'Apache 2.0' __version__ = '1.0' import time import numpy from PIL import Image import SightSpotUtil if __name__ == '__main__': print 'Calculate saliency map for test image:' image = Image.open('flower.jpg') rgb_image = numpy.asarray(image, dtype='float32') orgb_image = SightSpotUtil.eval_orgb_image(rgb_image) start = time.clock() saliency_map = SightSpotUtil.eval_saliency_map(orgb_image, 3.0, 60.0, 'auto') print 'Saliency map extracted in', time.clock() - start, 'sec.' start = time.clock() heatmap_image = SightSpotUtil.eval_heatmap(saliency_map) print 'Heatmap extracted in', time.clock() - start, 'sec.' saliency_image = Image.fromarray(saliency_map * 255) image.show('Source image') saliency_image.show('Saliency image') heatmap_image.show('Heatmap')
""" __author__ = 'Igor Ryabtsov aka Tinnulion' __copyright__ = 'Copyright (c) 2014' __license__ = 'Apache 2.0' __version__ = '1.0' import time import numpy from PIL import Image import SightSpotUtil if __name__ == '__main__': print 'Calculate saliency map for test image:' image = Image.open('flower.jpg') rgb_image = numpy.asarray(image, dtype='float32') orgb_image = SightSpotUtil.eval_orgb_image(rgb_image) start = time.clock() saliency_map = SightSpotUtil.eval_saliency_map(orgb_image, 3.0, 60.0, 'auto') print 'Saliency map extracted in', time.clock() - start, 'sec.' start = time.clock() heatmap_image = SightSpotUtil.eval_heatmap(saliency_map) print 'Heatmap extracted in', time.clock() - start, 'sec.' saliency_image = Image.fromarray(saliency_map * 255) image.show('Source image') saliency_image.show('Saliency image') heatmap_image.show('Heatmap')