Ejemplo n.º 1
0
    def runSaliency(self):

        # get the saliency maps using the 3 implemented methods
        #rbd = psal.get_saliency_rbd(self.filename).astype('uint8')
        
        ft = psal.get_saliency_ft(self.filename).astype('uint8')
        
        mbd = psal.get_saliency_mbd(self.filename).astype('uint8')
        
        # often, it is desirable to have a binary saliency map
        binary_sal = psal.binarise_saliency_map(mbd,method='adaptive')
        
        img = cv2.imread(self.filename)
        
        cv2.imshow('img',img)
        #cv2.imshow('rbd',rbd)
        cv2.imshow('ft',ft)
        cv2.imshow('mbd',mbd)
        
        #openCV cannot display numpy type 0, so convert to uint8 and scale
        cv2.imshow('binary',255 * binary_sal.astype('uint8'))
        
        
        cv2.waitKey(0)
        cv2.destroyAllWindows()
Ejemplo n.º 2
0
def calcualteSaliencyMaps(filename):
    # get the saliency maps using the 3 implemented methods
    rbd = psal.get_saliency_rbd(filename).astype('uint8')

    ft = psal.get_saliency_ft(filename).astype('uint8')

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

    # often, it is desirable to have a binary saliency map
    mbd_binary_sal = psal.binarise_saliency_map(mbd,method='adaptive')
    ft_binary_sal = psal.binarise_saliency_map(ft,method='adaptive')
    rbd_binary_sal = psal.binarise_saliency_map(rbd,method='adaptive')

    return (rbd, ft, mbd, rbd_binary_sal, ft_binary_sal, mbd_binary_sal)
Ejemplo n.º 3
0
def saliency_4(frame, threshold=0.5):

    #candidate 3
    #https://github.com/yhenon/pyimgsaliency

    #get the saliency maps using the 3 implemented methods
    ft = psal.get_saliency_ft(frame).astype('uint8') #R. Achanta, S. Hemami, F. Estrada and S. Süsstrunk, Frequency-tuned Salient Region Detection, IEEE International Conference on Computer Vision and Pattern Recognition (CVPR 2009), pp. 1597 - 1604, 2009

    #often, it is desirable to have a binary saliency map
    #check 'binarise.py'
    #the method can be either adaptive or fixed
    #binarise_saliency_map(saliency_map,method='adaptive',threshold=0.5)
    binary_ft = psal.binarise_saliency_map(ft, method='adaptive', threshold = threshold)
    return ft, 255*binary_ft.astype('uint8')
Ejemplo n.º 4
0
import pyimgsaliency as psal
import cv2

# path to the image
filename = 'bird.jpg'

# get the saliency maps using the 3 implemented methods
rbd = psal.get_saliency_rbd(filename).astype('uint8')

ft = psal.get_saliency_ft(filename).astype('uint8')

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

# often, it is desirable to have a binary saliency map
binary_sal = psal.binarise_saliency_map(mbd,method='adaptive')

img = cv2.imread(filename)

cv2.imshow('img',img)
cv2.imshow('rbd',rbd)
cv2.imshow('ft',ft)
cv2.imshow('mbd',mbd)

#openCV cannot display numpy type 0, so convert to uint8 and scale
cv2.imshow('binary',255 * binary_sal.astype('uint8'))


cv2.waitKey(0)
Ejemplo n.º 5
0
import numpy as np
import pyimgsaliency as psal
import cv2

if '__main__' == __name__:
    # path to the image
    filename = 'bird.jpg'

    # get the saliency maps using the 3 implemented methods
    rbd = psal.get_saliency_rbd(filename).astype(np.uint8)

    ft = psal.get_saliency_ft(filename).astype(np.uint8)

    mbd = psal.get_saliency_mbd(filename).astype(np.uint8)

    # often, it is desirable to have a binary saliency map
    binary_sal = psal.binarise_saliency_map(mbd, method='adaptive')

    img = cv2.imread(filename)

    cv2.imshow('img', img)
    cv2.imshow('rbd', rbd)
    cv2.imshow('ft', ft)
    cv2.imshow('mbd', mbd)

    # OpenCV cannot display numpy type 0, so convert to uint8 and scale
    cv2.imshow('binary', 255 * binary_sal.astype(np.uint8))

    cv2.waitKey(0)
Ejemplo n.º 6
0
import pyimgsaliency as psal
import cv2

# path to the image

filename = '/Users/zmalik/image-similarity-fusion/bird.jpg'

# get the saliency maps using the 3 implemented methods

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

ft = psal.get_saliency_ft(filename).astype('uint8')

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

# often, it is desirable to have a binary saliency map

binary_sal = psal.binarise_saliency_map(mbd, method='adaptive')

img = cv2.imread(filename)

cv2.imshow('img', img)
cv2.imshow('rbd', rbd)
cv2.imshow('ft', ft)
cv2.imshow('mbd', mbd)

# openCV cannot display numpy type 0, so convert to uint8 and scale

cv2.imshow('binary', 255 * binary_sal.astype('uint8'))

cv2.waitKey(0)
Ejemplo n.º 7
0
        except:
            pass

        for filename in os.listdir('./input/dataset/MSRA-B'):
            if filename.endswith('.jpg'):
                # Get RBD saliency map
                try:
                    # Unknown error handler
                    rbd = get_saliency_rbd('./input/dataset/MSRA-B/' + filename).astype('uint8')
                    cv2.imwrite('./input/unsup_labels/rdb/' + filename[:-4] + '_ngt.png', rbd)
                except:
                    with open('output/failed.txt', 'a+') as f:
                        f.write(filename + '\n')

                # Get FT saliency map
                ft = get_saliency_ft('./input/dataset/MSRA-B/' + filename).astype('uint8')
                cv2.imwrite('./input/unsup_labels/ft/' + filename[:-4] + '_ngt.png', ft)

                # Get MBD saliency map
                mbd = get_saliency_mbd('./input/dataset/MSRA-B/' + filename).astype('uint8')
                cv2.imwrite('./input/unsup_labels/mbd/' + filename[:-4] + '_ngt.png', mbd)
                
                # Get HC saliency map
                hc = get_saliency_hc('./input/dataset/MSRA-B/' + filename).astype('uint8')
                cv2.imwrite('./input/unsup_labels/hc/' + filename[:-4] + '_ngt.png', hc)

                # Get RC saliency map
                rc = get_saliency_rc('./input/dataset/MSRA-B/' + filename).astype('uint8')
                cv2.imwrite('./input/unsup_labels/rc/' + filename[:-4] + '_ngt.png', rc)
    else:
        path = "input/"