Beispiel #1
0
def main():
    """Takes in an image an converts it into a sepia image

    Returns:
        A sepia image is returned

    """
    parser = argparse.ArgumentParser(
    description='Converts an image into a sepia version of the original image.',
    formatter_class=argparse.RawTextHelpFormatter
    )


    parser.add_argument("-i", "--input", type=str, help="The input filename of file to apply filter to.", required=True)

    parser.add_argument("-sc", "--scale", type=float, help="Scale factor to resize image", default=1.0)

    parser.add_argument("-m", "--method",
                        help="Choose which implementation to use for filtering the image. ",
                        type=str, choices=['python', 'numpy', 'numba', 'cython'], default='numpy')

    parser.add_argument("-o", "--output", type=str, help="The output filename.", required=True)


    args = parser.parse_args()

    image = readImageFromFile(args.input)

    if args.scale != 1:
        image = cv2.resize(args.input, (0,0), fx=args.scale, fy=args.scale)

    if args.method == 'python':
        sepia_image = python_sepia(image)

    elif args.method == 'numpy':
        sepia_image = numpy_sepia(image)

    elif args.method == 'numba':
        sepia_image = numba_sepia(image)

    elif args.method == 'cython':
        sepia_image = cython_sepia(image)

    else:
        print("Wrong input given")



    writeImageToFile(sepia_image, args.output)
Beispiel #2
0
def main(input_filename, output_filename):
    """Reads an image from file,
    creates a gray version of the image, and writes
    the image to a file if output file is specified.

    Args:
        input_filename (str): Filename of the image

    """

    image = readImageFromFile(input_filename) # Reading in image from file

    gray_image = numba_grayscale(image) # Convert it to gray image

    writeImageToFile(gray_image, output_filename) # Write the gray image to file

    writeToReports(input_filename, image) # Write the reports
Beispiel #3
0
def main(input_filename, output_filename):
    """Reads an image from file,
    creates a sepia version of the image, and writes
    the image to a file if output file is specified.

    Args:
        input_filename (str): Filename of the image

    """

    image = readImageFromFile(input_filename)  # Reading in image from file

    sepia_image = python_sepia(image)  # Using sepia filter image

    writeImageToFile(sepia_image,
                     output_filename)  # Write the new image to file

    writeToReports(input_filename, image)  # Write the reports