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