|
|
|
@ -7,7 +7,6 @@
|
|
|
|
|
import argparse as ap
|
|
|
|
|
import sys
|
|
|
|
|
import json
|
|
|
|
|
import math
|
|
|
|
|
from os.path import exists
|
|
|
|
|
|
|
|
|
|
# Libraries for image processing
|
|
|
|
@ -159,7 +158,8 @@ class app:
|
|
|
|
|
"ksize", "kernel", "sigmaX", "sigmaY",
|
|
|
|
|
"sigmaColor", "sigmaSpace", "d", "anchor", "iterations",
|
|
|
|
|
"op", "strength", "amount", "radius", "weight", "channelAxis",
|
|
|
|
|
"theta", "sigma", "lambda", "gamma", "psi", "shape", "percent", "threshold"}
|
|
|
|
|
"theta", "sigma", "lambda", "gamma", "psi", "shape", "percent",
|
|
|
|
|
"threshold", "maxval", "type", "margin", "color"}
|
|
|
|
|
|
|
|
|
|
for key in possible_params:
|
|
|
|
|
if params.get(key) is None:
|
|
|
|
@ -208,17 +208,14 @@ class app:
|
|
|
|
|
|
|
|
|
|
# gets empty figure and ax with dimensions of input image
|
|
|
|
|
self.height, self.width = self.img.shape
|
|
|
|
|
fig, ax = self.get_empty_figure()
|
|
|
|
|
self.fig, ax = self.get_empty_figure()
|
|
|
|
|
|
|
|
|
|
# print("Height: " + str(self.height) + " px and width: "
|
|
|
|
|
# + str(self.width) + " px", file=sys.stderr)
|
|
|
|
|
|
|
|
|
|
if self.mirror is True:
|
|
|
|
|
self.mirror_image()
|
|
|
|
|
|
|
|
|
|
# Apply all filters and save image
|
|
|
|
|
self.apply_filters()
|
|
|
|
|
self.save_image(fig, ax)
|
|
|
|
|
self.save_image(self.fig, ax)
|
|
|
|
|
plt.close()
|
|
|
|
|
|
|
|
|
|
def get_empty_figure(self):
|
|
|
|
@ -260,7 +257,7 @@ class app:
|
|
|
|
|
|
|
|
|
|
# Colormap must be set to grayscale to avoid color mismatch.
|
|
|
|
|
ax.imshow(self.img, cmap="gray")
|
|
|
|
|
fig.savefig(fname=self.output_file, dpi=self.dpi)
|
|
|
|
|
fig.savefig(fname=self.output_file)
|
|
|
|
|
|
|
|
|
|
#------------------------- STL GENERATION -------------------------#
|
|
|
|
|
|
|
|
|
@ -336,8 +333,7 @@ class app:
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
# TODO: somehow compress this to fit it onto the model
|
|
|
|
|
self.id = self.input_file.split(
|
|
|
|
|
"/")[-1].split(".")[0] + "_" + self.preset_name
|
|
|
|
|
self.id = self.input_file.split("/")[-1].split(".")[0] + "_" + self.preset_name
|
|
|
|
|
# TODO: hash is not unique, find a better way
|
|
|
|
|
# TODO: stl file format has 80 chars for header, use that space to store info
|
|
|
|
|
# python generates a random value for security reasons, it has to be turned off
|
|
|
|
@ -615,6 +611,7 @@ class app:
|
|
|
|
|
def save_stl(self):
|
|
|
|
|
'''Save final mesh to stl file.
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
# TODO: add a hash function to create ID specific to
|
|
|
|
|
# input image + preset from config. file or from console + input params
|
|
|
|
|
# TODO: add the full parameters and filters to a file inside output dir.
|
|
|
|
|