|
|
@ -14,15 +14,22 @@ import filters as flt
|
|
|
|
|
|
|
|
|
|
|
|
class apply_filters:
|
|
|
|
class apply_filters:
|
|
|
|
def __init__(self):
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
# Parse and save arguments.
|
|
|
|
self.parse_arguments()
|
|
|
|
self.parse_arguments()
|
|
|
|
self.input_file = self.args.input_file
|
|
|
|
self.input_file = self.args.input_file
|
|
|
|
self.output_file = self.args.output_file
|
|
|
|
self.output_file = self.args.output_file
|
|
|
|
|
|
|
|
self.dpi = self.args.dpi # should be around 500-1000dpi
|
|
|
|
|
|
|
|
self.filters = self.args.filters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Read input image, save its dimensions
|
|
|
|
self.img = plt.imread(self.input_file)
|
|
|
|
self.img = plt.imread(self.input_file)
|
|
|
|
self.dimensions = self.img.shape
|
|
|
|
self.dimensions = self.img.shape
|
|
|
|
self.print_debug(self.dimensions)
|
|
|
|
self.print_debug(self.dimensions)
|
|
|
|
self.dpi = self.args.dpi # should be around 500-1000dpi
|
|
|
|
|
|
|
|
|
|
|
|
# Convert dimensions
|
|
|
|
self.convert_dpi()
|
|
|
|
self.convert_dpi()
|
|
|
|
self.filters = self.args.filters
|
|
|
|
|
|
|
|
|
|
|
|
# Apply all filters
|
|
|
|
self.apply_filter()
|
|
|
|
self.apply_filter()
|
|
|
|
|
|
|
|
|
|
|
|
def parse_arguments(self):
|
|
|
|
def parse_arguments(self):
|
|
|
@ -64,7 +71,6 @@ class apply_filters:
|
|
|
|
filter.apply(self)
|
|
|
|
filter.apply(self)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
for filter_name in self.filters:
|
|
|
|
for filter_name in self.filters:
|
|
|
|
# only one takse effect?
|
|
|
|
|
|
|
|
filter = self.filter_factory(filter_name)
|
|
|
|
filter = self.filter_factory(filter_name)
|
|
|
|
filter.apply(self)
|
|
|
|
filter.apply(self)
|
|
|
|
self.save_image()
|
|
|
|
self.save_image()
|
|
|
@ -75,7 +81,7 @@ class apply_filters:
|
|
|
|
#print("Channels: " + str(dimensions[2]))
|
|
|
|
#print("Channels: " + str(dimensions[2]))
|
|
|
|
|
|
|
|
|
|
|
|
def save_image(self):
|
|
|
|
def save_image(self):
|
|
|
|
# Save processed image
|
|
|
|
''' Save processed image. '''
|
|
|
|
plt.xticks([]), plt.yticks([])
|
|
|
|
plt.xticks([]), plt.yticks([])
|
|
|
|
plt.axis('off')
|
|
|
|
plt.axis('off')
|
|
|
|
plt.savefig(self.output_file)
|
|
|
|
plt.savefig(self.output_file)
|
|
|
|