コード例 #1
0
def estimateResultFunc(data_name, target_name, N_32F, L_g, I_32F, A_8U, method_name, estimate_func):
    L_g = normalizeVector(L_g)
    silhouette_curve, S_8U = silhoutteCurve(A_8U)
    N_sil = silhouetteNormal(A_8U)
    silhouette_curve.setNormalImage(N_sil)

    N_sil = silhouette_curve.normals()

    cvs_sil = silhouette_curve.CVs()

    I_sil = np.array([I_32F[cv[1], cv[0]] for cv in cvs_sil])

    input_data = {"N_sil": N_sil, "I_sil": I_sil, "cvs_sil": cvs_sil, "I": I_32F, "A": A_8U}

    fig = plt.figure(figsize=(8, 8))
    fig.suptitle("Light estimation: %s" % method_name)
    fig.subplots_adjust(left=0.05, bottom=0.05, right=0.95, top=0.82, wspace=0.02, hspace=0.4)

    plt.subplot(2, 2, 1)
    plt.title("Ground truth")
    showLightSphere(plt, L_g)
    plt.axis("off")

    plt.subplot(2, 2, 2)
    plt.title("Illumination")

    A_32F = to32F(A_8U)
    I_org = I_32F * A_32F
    plt.gray()
    plt.imshow(I_org)
    plt.axis("off")

    output_data = estimate_func(input_data)
    L = output_data["L"]
    L = normalizeVector(L)
    L_error = angleError(L_g, L)
    plt.subplot(2, 2, 3)
    plt.title("Estimated error\n %4.1f $^\circ$" % L_error)
    showLightSphere(plt, L)
    plt.axis("off")

    I_est = lambert.diffuse(N_32F, L) * A_32F
    plt.subplot(2, 2, 4)
    plt.gray()
    plt.imshow(I_est)
    plt.axis("off")

    result_dir = resultDir("LightEstimation/%s" % data_name)
    result_file = resultFile(result_dir, "%s_%s" % (target_name, method_name))
    plt.savefig(result_file)
コード例 #2
0
ファイル: diffuse.py プロジェクト: tody411/InverseToon
def loadData(data_name, L=np.array([0, 0, 1])):
    N_32F, A_8U = normal.loadData(data_name)
    I_32F = lambert.diffuse(N_32F, L)
    return I_32F, A_8U