Esempio n. 1
0
def performanceTest(image_file):
    C_8U = loadRGB(image_file)
    C_32F = to32F(C_8U)

    h, w = C_32F.shape[:2]
    image_size_str = "Image size: %s x %s" %(w, h)

    fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(8, 8))
    fig.subplots_adjust(left=0.1, right=0.7, top=0.86, hspace=0.4)

    fig.suptitle("Peformance of guided filter\n%s" % image_size_str)

    filter_types = {"Bilateral Filter": (BilateralFilter, "r"),
                    "Guided Filter": (GuidedFilter, "g"),
                    "Fast Guided Filter": (FastGuidedFilter, "b")}

    sigmas = range(3, 31, 2)
    axes[0].set_title('For small radius $r$')

    performanceTestSigmas(C_32F, sigmas, filter_types, axes[0])

    sigmas = range(10, 100, 5)

    filter_types = {"Guided Filter": (GuidedFilter, "g"),
                    "Fast Guided Filter": (FastGuidedFilter, "b")}

    axes[1].set_title('For large radius $r$')
    performanceTestSigmas(C_32F, sigmas, filter_types, axes[1])

    result_name = "performance"
    result_file = resultFile(result_name)
    plt.savefig(result_file)
Esempio n. 2
0
def GuidedFilter(input_imagefile, guidance_imgfile):
    image_name = os.path.basename(input_imagefile)
    image_name = os.path.splitext(image_name)[0]

    C_Input_8U = loadRGB(input_imagefile)
    C_Input_32F = to32F(C_Input_8U)

    C_Guidnace_8U = loadRGB(guidance_imgfile)
    C_Guidnace_32F = to32F(C_Guidnace_8U)

    aspect = C_Input_32F.shape[0] / float(C_Input_32F.shape[1])

    fig_width = 10
    fig_height = int(2 * fig_width * aspect / 3) + 2
    fig = plt.figure(figsize=(fig_width, fig_height))
    fig.subplots_adjust(left=0.05,
                        bottom=0.05,
                        right=0.95,
                        top=0.82,
                        wspace=0.02,
                        hspace=0.3)
    h, w = C_Input_32F.shape[:2]
    image_size_str = "Image size: %s x %s" % (w, h)
    fig.suptitle("Filtering noise image\n%s" % image_size_str)

    # plt.subplot(231)
    # plt.title("Original")
    # plt.imshow(C_Input_32F)
    # plt.axis('off')

    h, w, cs = C_Input_32F.shape

    plt.subplot(232)
    plt.title("input img")
    plt.imshow(C_Input_32F)
    plt.axis('off')

    sigmas = [5, 10, 20]

    plot_id = 234
    for sigma in sigmas:
        guided_filter = FastGuidedFilter(C_Guidnace_32F,
                                         radius=sigma,
                                         epsilon=0.02)
        C_smooth = guided_filter.filter(C_Input_32F)
        C_smooth = np.clip(C_smooth, 0.0, 1.0)

        plt.subplot(plot_id)
        plt.title("Filtered ($r$=%s)" % sigma)
        plt.imshow(C_smooth)
        plt.axis('off')
        plot_id += 1

    result_file = resultFile(image_name)
    plt.savefig(result_file)
Esempio n. 3
0
def runSmoothNoiseResult(image_file):
    image_name = os.path.basename(image_file)
    image_name = os.path.splitext(image_name)[0]

    C_8U = loadRGB(image_file)
    C_32F = to32F(C_8U)

    aspect = C_32F.shape[0] / float(C_32F.shape[1])

    fig_width = 10
    fig_height = int(2 * fig_width * aspect / 3) + 2
    fig = plt.figure(figsize=(fig_width, fig_height))
    fig.subplots_adjust(left=0.05, bottom=0.05, right=0.95, top=0.82, wspace=0.02, hspace=0.3)
    h, w = C_32F.shape[:2]
    image_size_str = "Image size: %s x %s" %(w, h)
    fig.suptitle("Filtering noise image\n%s" % image_size_str)

    plt.subplot(231)
    plt.title("Original")
    plt.imshow(C_32F)
    plt.axis('off')

    h, w, cs = C_32F.shape

    C_noise = np.float32(C_32F + 0.3 * np.random.rand(h, w, cs))
    C_noise = np.clip(C_noise, 0.0, 1.0)

    plt.subplot(232)
    plt.title("Noise")
    plt.imshow(C_noise)
    plt.axis('off')

    sigmas = [5, 10, 20]

    plot_id = 234
    for sigma in sigmas:
        guided_filter = FastGuidedFilter(C_noise, radius=sigma, epsilon=0.02)
        C_smooth = guided_filter.filter(C_noise)
        C_smooth = np.clip(C_smooth, 0.0, 1.0)

        plt.subplot(plot_id)
        plt.title("Filtered ($r$=%s)" %sigma)
        plt.imshow(C_smooth)
        plt.axis('off')
        plot_id +=1

    result_file = resultFile(image_name)
    plt.savefig(result_file)
Esempio n. 4
0
def performanceTest(image_file):
    C_8U = loadRGB(image_file)
    C_32F = to32F(C_8U)

    h, w = C_32F.shape[:2]
    image_size_str = "Image size: %s x %s" % (w, h)

    fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(8, 8))
    fig.subplots_adjust(left=0.1, right=0.7, top=0.86, hspace=0.4)

    fig.suptitle("Peformance of guided filter\n%s" % image_size_str)

    filter_types = {
        "Bilateral Filter": (BilateralFilter, "r"),
        "Guided Filter": (GuidedFilter, "g"),
        "Fast Guided Filter": (FastGuidedFilter, "b")
    }

    sigmas = range(3, 31, 2)
    axes[0].set_title('For small radius $r$')

    performanceTestSigmas(C_32F, sigmas, filter_types, axes[0])

    sigmas = range(10, 100, 5)

    filter_types = {
        "Guided Filter": (GuidedFilter, "g"),
        "Fast Guided Filter": (FastGuidedFilter, "b")
    }

    axes[1].set_title('For large radius $r$')
    performanceTestSigmas(C_32F, sigmas, filter_types, axes[1])

    result_name = "performance"
    result_file = resultFile(result_name)
    plt.savefig(result_file)