Esempio n. 1
0
def imagetestplt(thetainput, doubleopponencyinput):
    """Summary
    Display function that generates the final output images using MatplotLib windows
    Args:
        thetainput (float): a threshold value for perception
        doubleopponencyinput (bool): A boolean toggle for changing the opponency mode
    """
    theta = thetainput
    rgcMode = doubleopponencyinput

    C = retina.sample(img, x, y, coeff[i], loc[i],
                      rgb=True)  # CENTRE(sharp retina)
    S = retina.sample(img, x, y, dcoeff[i], dloc[i],
                      rgb=True)  # SURROUND(blurred retina)

    if rgcMode == 0:
        pV, nV = rgc.opponency(C, S, theta)
    else:
        pV, nV = rgc.doubleopponency(C, S, theta)

    rIntensity, cIntensity = showNonOpponency(C, theta)
    # Construct window plots
    plt.subplot(3, 1, 1), plt.imshow(cv2.cvtColor(
        img, cv2.COLOR_BGR2RGB)), plt.title('Original test image')
    plt.xticks([]), plt.yticks([])
    plt.subplot(3, 1, 2), plt.imshow(
        cv2.cvtColor(rIntensity, cv2.COLOR_BGR2RGB)), plt.title(
            'Backprojected R+G Intensity Response')
    plt.xticks([]), plt.yticks([])
    plt.subplot(3, 1, 3), plt.imshow(
        cv2.cvtColor(
            cIntensity,
            cv2.COLOR_BGR2RGB)), plt.title('Cortical R+G Intensity Response')
    plt.xticks([]), plt.yticks([])
    # format float to string
    thetastring = "%.2f" % theta
    plt.suptitle('Rectified DoG Intensity Images. Threshold:' + thetastring,
                 fontsize=16)
    plt.show()

    #Generate backprojected images
    if showInverse:
        rOpponent = showBPImg(pV, nV)
        plt.imshow(cv2.cvtColor(rOpponent, cv2.COLOR_BGR2RGB)), plt.title(
            'Backprojected Opponent Cells Output')
        plt.xticks([]), plt.yticks([])
        plt.show()
    # Cortex
    if showCortex:
        cOpponent = showCortexImg(pV, nV)
        plt.imshow(cv2.cvtColor(
            cOpponent,
            cv2.COLOR_BGR2RGB)), plt.title('Cortex Opponent Cells Output')
        plt.xticks([]), plt.yticks([])
        plt.show()
Esempio n. 2
0
def imagetest(thetainput, doubleopponencyinput):
    """Summary
    Display function that generates the final output images using opencv windows
    Args:
        thetainput (float): a threshold value for perception
        doubleopponencyinput (bool): A boolean toggle for changing the opponency mode
    """
    theta = thetainput
    rgcMode = doubleopponencyinput

    C = retina.sample(img, x, y, coeff[i], loc[i], rgb=True)  # CENTRE
    S = retina.sample(img, x, y, dcoeff[i], dloc[i], rgb=True)  # SURROUND

    if rgcMode == 0:
        pV, nV = rgc.opponency(C, S, theta)
    else:
        pV, nV = rgc.doubleopponency(C, S, theta)
    cv2.namedWindow("Input", cv2.WINDOW_NORMAL)
    cv2.imshow("Input", img)
    rIntensity, cIntensity = showNonOpponency(C, theta)
    cv2.namedWindow("Intensity Responses", cv2.WINDOW_NORMAL)
    cv2.imshow("Intensity Responses", rIntensity)
    cv2.namedWindow("Intensity Responses Cortex", cv2.WINDOW_NORMAL)
    cv2.imshow("Intensity Responses Cortex", cIntensity)
    cv2.waitKey(0)
    #Generate backprojected images
    if showInverse:
        rOpponent = showBPImg(pV, nV)
        cv2.namedWindow("Backprojected Opponent Cells Output",
                        cv2.WINDOW_NORMAL)
        cv2.imshow("Backprojected Opponent Cells Output", rOpponent)
        cv2.waitKey(0)
    # Cortex
    if showCortex:
        cOpponent = showCortexImg(pV, nV)
        cv2.namedWindow("Cortex Opponent Cells Output", cv2.WINDOW_NORMAL)
        cv2.imshow("Cortex Opponent Cells Output", cOpponent)
        cv2.waitKey(0)
Esempio n. 3
0
        imgsize = (img.shape[0], img.shape[1])

        theta = cv2.getTrackbarPos('theta', 'Input') / 100.0
        rgcMode = cv2.getTrackbarPos(switch, 'Input')

        # sample images
        C = retina.sample(img, x, y, coeff[i], loc[i],
                          rgb=True)  # CENTRE(sharp retina)
        S = retina.sample(img, x, y, dcoeff[i], dloc[i],
                          rgb=True)  # SURROUND(blurred retina)

        # generate rectified imagevectors based on the type of opponency
        if rgcMode == 0:
            pV, nV = rgc.opponency(C, S, theta)
        else:
            pV, nV = rgc.doubleopponency(C, S, theta)

        # Display functions are called
        cv2.imshow("Input", img)

        rIntensity, cIntensity = showNonOpponency(C, theta)
        cv2.imshow("Intensity Responses", rIntensity)
        cv2.namedWindow("Intensity Responses Cortex", cv2.WINDOW_NORMAL)
        cv2.imshow("Intensity Responses Cortex", cIntensity)
        #Generate backprojected images
        if showInverse:
            rOpponent = showBPImg(pV, nV)
            cv2.namedWindow("Backprojected Opponent Cells Output",
                            cv2.WINDOW_NORMAL)
            cv2.imshow("Backprojected Opponent Cells Output", rOpponent)
        # Cortex