diff --git a/src/main.py b/src/main.py index f3a281b..d424219 100644 --- a/src/main.py +++ b/src/main.py @@ -8,6 +8,8 @@ import argparse as ap import json import numpy as np import matplotlib.pyplot as plt +from PIL import Image +import cv2 as cv # Import custom image filter library import filters as flt @@ -20,6 +22,7 @@ class apply_filters: self.output_file = self.args.output_file self.dpi = self.args.dpi # should be around 500-1000dpi self.filters = self.args.filters + self.flip = self.args.flip # Read input image, save its dimensions self.img = plt.imread(self.input_file) @@ -33,13 +36,18 @@ class apply_filters: self.apply_filter() 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 = ap.ArgumentParser(prog = 'main.py', description = 'Program for processing a 2D image into 3D fingerprint.') + + # positional arguments + parser.add_argument("input_file", type = str, help = "Location with input file") + parser.add_argument("output_file", type = str, help = "Output file location") + parser.add_argument("dpi", type = int, help = "Scanner dpi") + parser.add_argument('-f', "--flip", help="Flip input image", + type = bool, action = ap.BooleanOptionalAction) # boolean switch + # file with default presets - #parser.add_argument('-pf', "--preset_file") - parser.add_argument('filters', type = str, nargs = '*') + parser.add_argument('-pf', "--preset_file", help = "File with presets") + parser.add_argument('filters', type = str, nargs = '*', help = "List of filter names") self.args = parser.parse_args() def convert_dpi(self): @@ -59,12 +67,15 @@ class apply_filters: else: raise ValueError("Invalid filter name") - def resize_img(self): + def process_image(self): # resize img to the new width - if(False): - print('') + # flip image when mirroring is needed + if self.flip: + print("Flipping image") + self.img = cv.flip(self.img, 1) def apply_filter(self): + self.process_image() if len(self.filters) == 0: # save original image filter = flt.filter_none @@ -78,7 +89,6 @@ class apply_filters: def print_debug(self, dimensions): print("Height: " + str(dimensions[0])) print("Width: " + str(dimensions[1])) - #print("Channels: " + str(dimensions[2])) def save_image(self): ''' Save processed image. '''