Esempio n. 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)
Esempio n. 2
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')
Esempio n. 3
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)
Esempio n. 4
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)
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)
Esempio n. 6
0
        try:
            os.mkdir('./input/unsup_labels/')
            os.mkdir('./input/unsup_labels/rdb')
            os.mkdir('./input/unsup_labels/ft')
            os.mkdir('./input/unsup_labels/mbd')
            os.mkdir('./input/unsup_labels/hc')
            os.mkdir('./input/unsup_labels/rc')
        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')