예제 #1
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)
예제 #2
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()
예제 #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')
예제 #4
0
def saliency_5(frame, threshold=0.5):

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

    #get the saliency maps using the 3 implemented methods
    mbd = psal.get_saliency_mbd(frame).astype('uint8') #Jianming Zhang, Stan Sclaroff, Zhe Lin, Xiaohui Shen, Brian Price and Radomír Měch. "Minimum Barrier Salient Object Detection at 80 FPS."

    #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_mbd = psal.binarise_saliency_map(mbd,method='adaptive',threshold=threshold)

    return mbd, 255*binary_mbd.astype('uint8')
예제 #5
0
def saliency_3(frame, threshold=0.5):

    #candidate 3
    #https://github.com/yhenon/pyimgsaliency
    #Saliency Optimization from Robust Background Detection, Wangjiang Zhu, Shuang Liang, Yichen Wei and Jian Sun, IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2014

    rbd = psal.get_saliency_rbd(frame).astype('uint8')
    #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_rbd = psal.binarise_saliency_map(rbd, method='adaptive', threshold = threshold)
    #openCV cannot display numpy type 0, so convert to uint8 and scale
    #cv2.imshow('binary',255 * binary_sal.astype('uint8'))

    return rbd, 255*binary_rbd.astype('uint8')
예제 #6
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)
예제 #7
0
파일: demo.py 프로젝트: mamrehn/pysal
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)