CLT29 / OpenSALICON

An open source implementation of the SALICON saliency model
73 stars 17 forks source link

map = sal.compute_saliency('face.jpg') #4

Closed sunnycia closed 7 years ago

sunnycia commented 7 years ago

Hey chris , I tried to use these code to get a saliency map of face.jpg from Salicon import Salicon from PIL import Image import numpy as np sal = Salicon() map = sal.compute_saliency("face.jpg") img = Image.fromarray(map, mode="L") img.save("face_saliency.jpg")

Then I got a picture of chaos. I checked out the content of the ndarray print map I found that the items in this ndarray are not integers between 1 and 255. What are those float numbers stand for? What should I do with these number in order to get a correct saliency map? Gracias ;)

sunnycia commented 7 years ago

@CLT29

zhangqiudan commented 7 years ago

I have also encountered this problem, so how to solve this problem? @CLT29

sunnycia commented 7 years ago

Problem solved. from Salicon import Salicon import cv2 import numpy as np sal = Salicon() pred = sal.compute_saliency("face.jpg") map = pred / np.max(pred) * 255 cv2.imwrite("output.jpg", map.astype(int))

CLT29 commented 7 years ago

The float numbers between [0,1] are image intensity values. You will need to scale those to your desired range (e.g. 255) before using. Glad you figured it out.