コード例 #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
コード例 #2
0
            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)

            cv2.imshow('static sal', sal)
            cv2.waitKey(2)

            # move joints
            vrep.simxSetJointTargetPosition(clientID, joint_z,\
                    get_x_joint_pos(np.pi/4, 256, max_sal_arg[0]),\
                    vrep.simx_opmode_oneshot)