"""! @file main.py @brief Main file for the application @author xlanro00 """ # Import libraries import argparse as ap import json import numpy as np import matplotlib.pyplot as plt # Import custom image filter library import filters as flt parser = ap.ArgumentParser(prog='main.py', description='loads and stores image') parser.add_argument("-i", "--input_file", help="Input file", required=True) parser.add_argument("-o", "--output_file", help="Output file", required=True) parser.add_argument('-d', "--dpi", type=int, required=True) #parser.add_argument( '-s', '--size') parser.add_argument('filters', type=str, nargs='*') args = parser.parse_args() class app: def __init__(self, input_file, output_file, dpi, filters): self.input_file = input_file self.output_file = output_file self.img = plt.imread(self.input_file) self.dpi = dpi self.filters = filters self.apply_filters() def filter_factory(self, filter_name): if filter_name == "average": return flt.filter_average elif filter_name == "blur": return flt.filter_blur elif filter_name == "gaussian": return flt.filter_gaussian else: raise ValueError("Invalid filter name") def apply_filters(self): for filter in self.filters: filter = self.filter_factory(filter) filter.apply(self) self.save_image() def save_image(self): # Save processed image plt.savefig(self.output_file) app = app(args.input_file, args.output_file, args.dpi, args.filters)