def plotFeatureChanges(plt, ps, feature):
    epsilon = 0.001
    feature_min = np.min(feature)
    feature_max = np.max(feature)
    feature_range = feature_max - feature_min
    ofeature_changes_colors = featureTypeColors(feature, vmin=-feature_range * epsilon, vmax=feature_range * epsilon)
    plotSegment(plt, ps, ofeature_changes_colors)
def curvatureVSconeAnglesFigure(scnene_plotter, data_name, segment_id, result_data):
    fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(11, 5))
    font_size = 15
    fig.subplots_adjust(left=0.05, right=0.95, top=0.86, hspace=0.1, wspace=0.05)
    fig.suptitle("Curvature VS Cone Angle", fontsize=font_size)

    plt.subplot(131)
    scnene_plotter.showNormalImage()
    plt.axis("off")
    plt.title("Curvature\n", fontsize=font_size)
    plotFeatureChanges(plt, result_data["ps"], result_data["curvatures"])

    plt.subplot(132)
    scnene_plotter.showNormalImage()
    plt.axis("off")
    plt.title("Cone Angle\n", fontsize=font_size)
    plotFeatureChanges(plt, result_data["ps"], result_data["cone_angle_changes"])

    plt.subplot(133)
    scnene_plotter.showNormalImage()
    plt.axis("off")
    plt.title("Misclassification\n%5.1f %%" % (100 * result_data["misclassification_rate"]), fontsize=font_size)

    for segment in result_data["misclassification_segments"]:
        plotSegment(plt, segment, color=(0.8, 0.2, 0.2))

    result_name = "cone_vs_curvature/misclassification"
    result_dir = resultDir(result_name)

    result_file = resultFile(result_dir, data_name + "_%s" % segment_id)
    plt.savefig(result_file, transparent=True)
def arcVSprojectFigure(scnene_plotter, data_name, segment_id, result_data):
    fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(11, 5))
    font_size = 15
    fig.subplots_adjust(left=0.15, right=0.9, top=0.86, hspace=0.1, wspace=0.05)
    fig.suptitle("Arc-Length Interpolation VS Project 3D", fontsize=font_size)

    plt.subplot(131)
    plt.title('Normal Vectors\n', fontsize=font_size)
    scnene_plotter.showNormalImage()
    plt.axis('off')

    legend_gt = ("Ground Truth", (1.0, 0.0, 0.0))
    legend_al = ("Arc-Length", (0.0, 1.0, 0.0))
    legend_3d = ("Project 3D", (0.0, 0.0, 1.0))

    plotVectors(plt, result_data["ps"], result_data["normals_gt"], color=legend_gt[1], l=70, step=2)
    plotVectors(plt, result_data["ps"], result_data["normals_al"], color=legend_al[1], l=70, step=2)
    plotVectors(plt, result_data["ps"], result_data["normals_3D"], color=legend_3d[1], l=70, step=2)

    plt.legend(bbox_to_anchor=(0.2, 1), handles=[mpatches.Patch(color=legend_gt[1], label=legend_gt[0]),
                        mpatches.Patch(color=legend_al[1], label=legend_al[0]),
                        mpatches.Patch(color=legend_3d[1], label=legend_3d[0])])
    error_max = 30.0
    error_min = 0.0

    plt.subplot(132)
    scnene_plotter.showNormalImage()
    plt.axis('off')
    plt.title('Arc-Length Error\n %5.2f $^\circ$' %np.average(result_data["normals_al_error"]), fontsize=font_size)
    error_colors = scalarToColor(result_data["normals_al_error"], vmin=error_min, vmax=error_max)
    plotSegment(plt, result_data["ps"], error_colors)

    plt.subplot(133)
    scnene_plotter.showNormalImage()
    plt.axis('off')
    plt.title('Project 3D Error\n %5.2f $^\circ$' %np.average(result_data["normals_3d_error"]), fontsize=font_size)
    error_colors = scalarToColor(result_data["normals_3d_error"], vmin=error_min, vmax=error_max)
    plotSegment(plt, result_data["ps"], error_colors)

    ax_colorbar = fig.add_axes([0.9, 0.15, 0.03, 0.7])

    scalar_map = scalarMap(error_min, error_max)
    scalar_map.set_array([error_min, error_max])
    fig.colorbar(scalar_map, cax=ax_colorbar)

    result_name = "arc_vs_project"
    result_dir = resultDir(result_name)

    result_file = resultFile(result_dir, data_name + "_%s" % segment_id)
    plt.savefig(result_file, transparent=True)
def datasetFunc(data_name):
    scene = loadData(data_name)
    data_list = computeData(scene)

    plotter = ScenePlotter(scene, plt)

    plt.title('Arc Interpolation')
    plotter.showNormalImage()

    for data in data_list:
        error_colors = scalarToColor(data["normals_error"])

        plotSegment(plt, data["ps"], error_colors)

    showMaximize()
def curvatureVSconeAnglesNormal(scnene_plotter, data_name, segment_id, result_data):
    fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(11, 5))
    font_size = 15
    fig.subplots_adjust(left=0.05, right=0.9, top=0.86, hspace=0.1, wspace=0.05)
    fig.suptitle("Arc-Length Interpolation", fontsize=font_size)

    plt.subplot(131)
    scnene_plotter.showNormalImage()
    plt.axis("off")
    plt.title("Ground Truth\n", fontsize=font_size)
    plotSegment(plt, result_data["ps"], color=(0.5, 0.1, 0.1))
    # plotVectors(plt, result_data["ps"], result_data["normals_gt"], step=5)

    plt.subplot(132)
    scnene_plotter.showNormalImage()
    plt.axis("off")
    plt.title("Interpolated Normal\n", fontsize=font_size)
    plotNormalColors(plt, result_data["ps"], result_data["normals_al"])

    plt.subplot(133)
    plt.title("Interpolation Error\n %4.1f $^\circ$" % np.max(result_data["normals_al_error"]), fontsize=font_size)
    scnene_plotter.showNormalImage()
    plt.axis("off")

    error_min = 0.0
    error_max = 30.0
    # error_max = np.max([0.0, np.max(result_data["normals_al_error"])])
    error_colors = scalarToColor(result_data["normals_al_error"], vmin=error_min, vmax=error_max)
    plotSegment(plt, result_data["ps"], error_colors)

    ax_colorbar = fig.add_axes([0.9, 0.15, 0.03, 0.7])

    scalar_map = scalarMap(error_min, error_max)
    scalar_map.set_array([error_min, error_max])
    fig.colorbar(scalar_map, cax=ax_colorbar)

    result_name = "cone_vs_curvature/normal"
    result_dir = resultDir(result_name)

    result_file = resultFile(result_dir, data_name + "_%s" % segment_id)
    plt.savefig(result_file, transparent=True)
def curvatureVSconeAnglesSignal(scnene_plotter, data_name, segment_id, result_data):
    fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(11, 5))
    font_size = 15
    fig.subplots_adjust(left=0.05, right=0.9, top=0.86, hspace=0.1, wspace=0.05)
    fig.suptitle("Curvature VS Cone Angle", fontsize=font_size)

    plt.subplot(131)
    scnene_plotter.showNormalImage()
    plt.axis("off")
    plt.title("Curvature", fontsize=font_size)
    curvature_colors = scalarToColor(result_data["curvatures"], vmin=-1.0, vmax=1.0)
    plotSegment(plt, result_data["ps"], curvature_colors)

    plt.subplot(132)
    scnene_plotter.showNormalImage()
    plt.axis("off")
    plt.title("Cone Angle", fontsize=font_size)
    cone_colors = scalarToColor(result_data["cone_angle_changes"], vmin=-1.0, vmax=1.0)
    plotSegment(plt, result_data["ps"], cone_colors)

    plt.subplot(133)
    plt.title("Signals", fontsize=font_size)
    xs = np.arange(len(result_data["curvatures"]))
    curvatures = result_data["curvatures"]
    cone_angle_changes = result_data["cone_angle_changes"]
    rescaled_curvatures = rescaleCurvature(curvatures, [cone_angle_changes[0], cone_angle_changes[-1]])
    plt.plot(xs, curvatures, label="Curvature")
    plt.plot(xs, cone_angle_changes, label="Cone Angle")
    # plt.plot(xs, rescaled_curvatures, label='Rescaled Curvatures')
    plt.legend()

    result_name = "cone_vs_curvature/signal"
    result_dir = resultDir(result_name)

    result_file = resultFile(result_dir, data_name + "_%s" % segment_id)
    plt.savefig(result_file, transparent=True)