Error for images that have completely black background
Both cases are about mdb.
(1)

Traceback (most recent call last):
File ".../demo.py", line 54, in
(2)
Another example is a white background image:

raises warning /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/skimage/io/_io.py:132: UserWarning: sushi6-ST copy-mbd.png is a low contrast image warn('%s is a low contrast image' % fname)
The saliency map is also strange (completely black).

However, if I add some elements to its background, it works fine and results in a good saliency map.


please help me ImportError: No module named pyimgsaliency
I have same errors and it is very critical, your module would be very useful but we cannot use your work until this is fixed.
################ versions ##########################
python 3.5.2 numpy 1.13.3 scipy 1.0.0 sklearn 0.19.1
################ codes ##########################
image_path = "chem.png" # also tried with jpg version : image_path = "chem.jpg"
mbd = psal.get_saliency_mbd(image_path).astype('uint8') pi_mbd = ProcessedImage(mbd) pi_mbd.image.show()
######################## image #################

########## error ########################
--> 513 ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj) 514 return wrap(ainv.astype(result_t, copy=False)) 515 ~/tfenv/lib/python3.5/site-packages/numpy/linalg/linalg.py in _raise_linalgerror_singular(err, flag) 88 89 def _raise_linalgerror_singular(err, flag): ---> 90 raise LinAlgError("Singular matrix") 91 92 def _raise_linalgerror_nonposdef(err, flag):
LinAlgError: Singular matrix
A simple work-around that worked for me is to use the pseudo inverse in these cases. I.e., for each one:
try:
cov_left = np.linalg.inv(cov_left)
except:
cov_left = np.linalg.pinv(cov_left)
Is normal to have errors in flat color image with saliency methods due to the need to calculate the inverse matrix of image pieces, is something discussed even in literature, a solid fix is to add some noise to the image :
//untested
noise_mat = np.random.randint(4, size=img.size) - 2
img = np.clip(img + noise_mat , 0, 255) // avoid to have colors outside the valid range
this should do the work.