Added requirements for venv, removed some includes
This commit is contained in:
8
requirements.txt
Normal file
8
requirements.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
matplotlib==3.5.3
|
||||||
|
numpy==1.23.3
|
||||||
|
numpy-stl==3.0.0
|
||||||
|
opencv-python==4.7.0.72
|
||||||
|
scikit-image==0.19.3
|
||||||
|
scipy==1.9.3
|
||||||
|
stl==0.0.3
|
||||||
|
|
@ -4,11 +4,10 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
#import matplotlib.pyplot as plt
|
|
||||||
import cv2 as cv
|
import cv2 as cv
|
||||||
from skimage import filters as skiflt
|
from skimage import filters as skiflt
|
||||||
from skimage import restoration as skirest
|
from skimage import restoration as skirest
|
||||||
from scipy import signal as sig
|
#from scipy import signal as sig
|
||||||
|
|
||||||
|
|
||||||
# Parent class for all the filters
|
# Parent class for all the filters
|
||||||
@ -142,22 +141,27 @@ class denoise_bilateral(filter):
|
|||||||
super().__init__(img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self, params):
|
def apply(self, params):
|
||||||
|
|
||||||
|
# Standard deviation for grayvalue/color distance.
|
||||||
|
# A larger value results in averaging of pixels with larger radiometric differences.
|
||||||
sigmaColor = float(params["sigmaColor"]
|
sigmaColor = float(params["sigmaColor"]
|
||||||
) if params["sigmaColor"] else 0.1
|
) if params["sigmaColor"] else 0.1
|
||||||
|
|
||||||
|
# Standard deviation for range distance.
|
||||||
|
# A larger value results in averaging of pixels with larger spatial differences.
|
||||||
|
|
||||||
sigmaSpace = float(params["sigmaSpace"]
|
sigmaSpace = float(params["sigmaSpace"]
|
||||||
) if params["sigmaSpace"] else 15.0
|
) if params["sigmaSpace"] else 15.0
|
||||||
channelAxis = int(params["channelAxis"]
|
# Repetition of filter application.
|
||||||
) if params["channelAxis"] else None
|
|
||||||
iterations = int(params["iterations"]) if params["iterations"] else 1
|
iterations = int(params["iterations"]) if params["iterations"] else 1
|
||||||
|
|
||||||
#print("with params: sigma_color: " + str(sigmaColor) +
|
#print("with params: sigma_color: " + str(sigmaColor) +
|
||||||
# " sigma_spatial: " + str(sigmaSpace) + " channel_axis: " +
|
# " sigma_spatial: " + str(sigmaSpace) + " iterations: " + str(iterations))
|
||||||
# str(channelAxis) + " iterations: " + str(iterations))
|
|
||||||
|
|
||||||
for i in range(iterations):
|
for i in range(iterations):
|
||||||
self.img = skirest.denoise_bilateral(
|
self.img = skirest.denoise_bilateral(
|
||||||
self.img, sigma_color=sigmaColor,
|
self.img, sigma_color=sigmaColor,
|
||||||
sigma_spatial=sigmaSpace, channel_axis=channelAxis)
|
sigma_spatial=sigmaSpace, channel_axis=None)
|
||||||
|
|
||||||
|
|
||||||
class denoise_tv_chambolle(filter):
|
class denoise_tv_chambolle(filter):
|
||||||
@ -171,16 +175,18 @@ class denoise_tv_chambolle(filter):
|
|||||||
super().__init__(img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self, params):
|
def apply(self, params):
|
||||||
|
|
||||||
|
# Denoising weight. The greater weight, the more denoising.
|
||||||
weight = float(params["weight"]) if params["weight"] else 0.1
|
weight = float(params["weight"]) if params["weight"] else 0.1
|
||||||
channelAxis = int(params["channelAxis"]
|
|
||||||
) if params["channelAxis"] else None
|
# Maximal number of iterations used for the optimization.
|
||||||
iterations = int(params["iterations"]) if params["iterations"] else 1
|
iterations = int(params["iterations"]) if params["iterations"] else 1
|
||||||
|
|
||||||
#print("with params: weight: " + str(weight) +
|
#print("with params: weight: " + str(weight) +
|
||||||
# " channel_axis: " + str(channelAxis) + " iterations: " + str(iterations))
|
# " iterations: " + str(iterations))
|
||||||
for i in range(iterations):
|
for i in range(iterations):
|
||||||
self.img = skirest.denoise_tv_chambolle(
|
self.img = skirest.denoise_tv_chambolle(
|
||||||
self.img, weight=weight, channel_axis=channelAxis)
|
self.img, weight=weight, channel_axis=None)
|
||||||
|
|
||||||
|
|
||||||
class sharpen(filter):
|
class sharpen(filter):
|
||||||
@ -235,6 +241,7 @@ class unsharp_mask_scikit(filter):
|
|||||||
def apply(self, params):
|
def apply(self, params):
|
||||||
radius = int(params["radius"]) if params["radius"] else 3
|
radius = int(params["radius"]) if params["radius"] else 3
|
||||||
amount = float(params["amount"]) if params["amount"] else 1
|
amount = float(params["amount"]) if params["amount"] else 1
|
||||||
|
# TODO: i have no idea what this is or how to use it
|
||||||
channelAxis = int(params["channelAxis"]
|
channelAxis = int(params["channelAxis"]
|
||||||
) if params["channelAxis"] else None
|
) if params["channelAxis"] else None
|
||||||
|
|
||||||
|
@ -7,15 +7,14 @@
|
|||||||
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
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
#from PIL import Image
|
|
||||||
import cv2 as cv
|
import cv2 as cv
|
||||||
from stl import mesh
|
from stl import mesh
|
||||||
import math
|
|
||||||
|
|
||||||
# Import custom image filter library
|
# Import custom image filter library
|
||||||
import filters as flt
|
import filters as flt
|
||||||
@ -158,7 +157,7 @@ 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"}
|
"theta", "sigma", "lambda", "gamma", "psi", "shape"}
|
||||||
|
|
||||||
for key in possible_params:
|
for key in possible_params:
|
||||||
if params.get(key) is None:
|
if params.get(key) is None:
|
||||||
@ -576,7 +575,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 filename specific to input image and preset
|
||||||
if self.mode == "3d":
|
if self.mode == "3d":
|
||||||
self.mesh_finger.save(self.stl_file)
|
self.mesh_finger.save(self.stl_file)
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user