I_id_max = np.max(I_ids)

    Ns_bright = Ns[I_ids == I_id_max, :]
    L = np.sum(Ns_bright, axis=0)
    L = normalizeVector(L)
    print L
    return L


def estimateLightDir(input_data):
    N_sil = input_data["N_sil"]
    I_sil = input_data["I_sil"]
    cvs_sil = input_data["cvs_sil"]
    I_32F = input_data["I"]
    A_8U = input_data["A"]

    p_samples = foreGroundSamples(A_8U)
    plt.imshow(A_8U)
    plt.scatter(p_samples[:, 0], p_samples[:, 1])
    plt.show()

    N_lumo = lumoNormal(A_8U)

    L = estimateLightByCluster(N_lumo, I_32F, p_samples)
    output_data = {"L": L}

    return output_data

if __name__ == '__main__':
    testToon("Lumo", estimateLightDir)
#     plt.imshow(I_32F)
#     plt.scatter(I_max_coord[0], I_max_coord[1])
#     plt.show()
#     plt.clf()


def estimateLightDir(input_data):
    N_sil = input_data["N_sil"]
    I_sil = input_data["I_sil"]
    cvs_sil = input_data["cvs_sil"]
    I_32F = input_data["I"]
    A_8U = input_data["A"]

    N_lumo = lumoNormal(A_8U)
    plt.imshow(0.5 * N_lumo + 0.5)
    plt.show()

    L_phi = estimatePhi(N_sil, I_sil)

    output_data = {"L": L_phi}

#     L = estimateLbyDistance(cvs_sil, N_sil, I_32F)
#     output_data = {"L": L}
    L = estimateTheta(L_phi, cvs_sil, N_sil, I_32F, A_8U)
    # output_data = {"L": L }
    return output_data

if __name__ == '__main__':
    testToon("Voting", estimateLightDir)