"""! @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 class app: def __init__(self): self.parse_arguments() self.input_file = self.args.input_file self.output_file = self.args.output_file self.img = plt.imread(self.input_file) self.dpi = self.args.dpi self.filters = self.args.filters self.apply_filters() def parse_arguments(self): 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='*') self.args = parser.parse_args() 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()