yhenon / pyimgsaliency

A python toolbox for computing image saliency
Apache License 2.0
171 stars 53 forks source link

LinAlgError due to Singular Matrix #2

Closed Make42 closed 7 years ago

Make42 commented 7 years ago

With some images the algorithm

import saliency_triple as psal
psal.get_saliency_mbd(filename).astype('uint8')

throws an LinAlgError in

cov_left = np.linalg.inv(cov_left)
cov_right = np.linalg.inv(cov_right)

cov_top = np.linalg.inv(cov_top)
cov_bottom = np.linalg.inv(cov_bottom)

since one of cov_... can be singular. Using np.linalg.pinv does not work - the saliency map becomes solely black. I do not understand the algorithm good enough to improve one that. Could you please?

yhenon commented 7 years ago

Hi, Could you share an image that causes this issue? Thanks.

Make42 commented 7 years ago

Yes. These images caused the issue:

4837__small_nio_color 4837__small_io_color

Please try both.

Make42 commented 7 years ago

No progress?

yhenon commented 7 years ago

Hi, I haven't been able to replicate this issue. Using your image as test1.jpg

import pyimgsaliency as psal
import cv2

filename = 'test1.jpg'

mbd = psal.get_saliency_mbd(filename).astype('uint8')
rbd = psal.get_saliency_rbd(filename).astype('uint8')

cv2.imwrite('mbd.png',mbd)
cv2.imwrite('rbd.png',rbd)

Succesfully saves the images to disk (note that these algos are not designed for medical images, results may not be the best).

rbd

mbd

Can you please check that your packages are up to date (numpy, scipy and sklearn)? Can you also see if the source image is in a stange format (this does happen with medical images)? Input should be 8-bit RGB images.