Ejemplo n.º 1
0
def get_saliency(img):

    #Calculates img saliency, using NVT algorithm (Itti, 1998)

    intensty = saliency.intensityConspicuity(img)
    gabor = saliency.gaborConspicuity(img, 4)

    im = saliency.makeNormalizedColorChannels(img)
    rg = saliency.rgConspicuity(im)
    by = saliency.byConspicuity(im)
    c = rg + by
    sal = 1./3 * (saliency.N(intensty) + saliency.N(c) + saliency.N(gabor))
    sal = cv2.resize(sal, dsize=(img.shape[1],img.shape[0])) 
    #sal = (sal + magno)/2
    sal = sal.astype(np.uint8)

    return sal
Ejemplo n.º 2
0
        res,resolution,image=vrep.simxGetVisionSensorImage(clientID,v0,0,vrep.simx_opmode_buffer)
        if res==vrep.simx_return_ok:

            # converting image to rgb np array
            img = image
            img = np.array(img, dtype=np.uint8)
            img.resize([resolution[0], resolution[1], 3])
            temp = np.copy(img[:,:,2])
            img[:, :, 2] = img[:, :, 0]
            img[:, :, 0] = temp
            img = np.flipud(img)
            cv2.imshow('felipe', img)
            cv2.waitKey(2)

            #calculating saliency
            intensty = saliency.intensityConspicuity(img)
            gabor = saliency.gaborConspicuity(img, 4)

            im = saliency.makeNormalizedColorChannels(img)
            rg = saliency.rgConspicuity(im)
            by = saliency.byConspicuity(im)
            c = rg + by
            sal = 1./3 * (saliency.N(intensty) + saliency.N(c) + saliency.N(gabor))
            sal = cv2.resize(sal, dsize=(img.shape[1],img.shape[0])) 
            #sal = (sal + magno)/2
            sal = sal.astype(np.uint8)

            # finding the most salient point
            #max_sal_arg = np.unravel_index(np.argmax(sal), sal.shape)
            #print(max_sal_arg)