Exemplo n.º 1
0
            grayscale_image[i, j] += bgr_image[i, j, 0] * 0.07 + \
                bgr_image[i, j, 1] * 0.72 + \
                bgr_image[i, j, 2] * 0.21

    grayscale_image = grayscale_image.astype("uint8")

    if outfile is None:
        filename, file_extension = os.path.splitext(imagefile)
        cv2.imwrite(filename + "_grayscale" + file_extension, grayscale_image)
    else:
        cv2.imwrite(outfile, grayscale_image)


if __name__ == "__main__":
    import sys

    sys.path.insert(0, '../profiling/')
    from manual_timing_ import timer_results

    # Visual verification of implementation
    python_color2gray("../images/rain.jpg")

    # Profile time
    imagefile = "../images/laperm_kitten.jpg"  # shape: (1537, 2305, 3)
    n_experiments = 5
    funcs = [python_color2gray]
    args = [imagefile]

    timer_results(
        n_experiments, "./reports/python_report_color2gray.txt", funcs, args)
Exemplo n.º 2
0
            else:
                sepia_image[i, j, 2] = R

    return sepia_image


if __name__ == "__main__":
    import sys

    from numpy_color2sepia import numpy_color2sepia
    from python_color2sepia import python_color2sepia

    sys.path.insert(0, '../profiling/')
    from manual_timing_ import timer_results

    # Visual verification of implementation
    # Also important to call function once before profiling time
    numba_color2sepia("../images/rain.jpg")

    # Profile time
    imagefile = "../images/laperm_kitten.jpg"  # shape: (1537, 2305, 3)
    n_experiments = 5
    funcs = [python_color2sepia, numpy_color2sepia, numba_color2sepia]
    args = [imagefile, imagefile, imagefile]

    timer_results(n_experiments,
                  "./reports/numba_report_color2sepia.txt",
                  funcs,
                  args,
                  order="numba_color2sepia")
Exemplo n.º 3
0
    if outfile is None:
        filename, file_extension = os.path.splitext(imagefile)
        cv2.imwrite(filename + "_grayscale" + file_extension, grayscale_image)
    else:
        cv2.imwrite(outfile, grayscale_image)


if __name__ == "__main__":
    import sys

    from python_color2gray import python_color2gray

    sys.path.insert(0, '../profiling/')
    from manual_timing_ import timer_results

    # Visual verification of implementation
    numpy_color2gray("../images/rain.jpg")

    # Profile time
    imagefile = "../images/laperm_kitten.jpg"  # shape: (1537, 2305, 3)
    n_experiments = 5
    funcs = [python_color2gray, numpy_color2gray]
    args = [imagefile, imagefile]

    timer_results(n_experiments,
                  "./reports/numpy_report_color2gray.txt",
                  funcs,
                  args,
                  order="numpy_color2gray")
Exemplo n.º 4
0
"""

if __name__ == "__main__":
    import sys

    from cython_color2sepia import cython_color2sepia
    from numba_color2sepia import numba_color2sepia
    from numpy_color2sepia import numpy_color2sepia
    from python_color2sepia import python_color2sepia

    sys.path.insert(0, '../profiling/')
    from manual_timing_ import timer_results

    # Visual verification of implementation
    cython_color2sepia("../images/rain.jpg")

    # Profile time
    imagefile = "../images/laperm_kitten.jpg"  # shape: (1537, 2305, 3)
    numba_color2sepia(imagefile)  # call once before benchmark
    n_experiments = 5
    funcs = [
        python_color2sepia, numpy_color2sepia, numba_color2sepia,
        cython_color2sepia
    ]
    args = [imagefile, imagefile, imagefile, imagefile]
    timer_results(n_experiments,
                  "./reports/cython_report_color2sepia.txt",
                  funcs,
                  args,
                  order="cython_color2sepia")
if __name__ == "__main__":
    import sys

    from cython_color2gray_cdef import cython_color2gray_cdef
    from cython_color2gray_cpdef import cython_color2gray_cpdef
    from numba_color2gray import numba_color2gray
    from numpy_color2gray import numpy_color2gray
    from python_color2gray import python_color2gray

    sys.path.insert(0, '../profiling/')
    from manual_timing_ import timer_results

    # Visual verification of implementation
    cython_color2gray_cdef("../images/rain.jpg")
    cython_color2gray_cpdef("../images/rain.jpg")

    # Profile time
    imagefile = "../images/laperm_kitten.jpg"  # shape: (1537, 2305, 3)
    numba_color2gray(imagefile)  # call once before benchmark
    n_experiments = 5
    funcs = [
        python_color2gray, numpy_color2gray, numba_color2gray,
        cython_color2gray_cdef, cython_color2gray_cpdef
    ]
    args = [imagefile, imagefile, imagefile, imagefile, imagefile]
    timer_results(n_experiments,
                  "./reports/cython_report_color2gray.txt",
                  funcs,
                  args,
                  order="cython_color2gray_cdef")