Added requirements for venv, removed some includes
This commit is contained in:
@ -4,11 +4,10 @@
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
#import matplotlib.pyplot as plt
|
||||
import cv2 as cv
|
||||
from skimage import filters as skiflt
|
||||
from skimage import restoration as skirest
|
||||
from scipy import signal as sig
|
||||
#from scipy import signal as sig
|
||||
|
||||
|
||||
# Parent class for all the filters
|
||||
@ -142,22 +141,27 @@ class denoise_bilateral(filter):
|
||||
super().__init__(img)
|
||||
|
||||
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"]
|
||||
) 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"]
|
||||
) if params["sigmaSpace"] else 15.0
|
||||
channelAxis = int(params["channelAxis"]
|
||||
) if params["channelAxis"] else None
|
||||
# Repetition of filter application.
|
||||
iterations = int(params["iterations"]) if params["iterations"] else 1
|
||||
|
||||
#print("with params: sigma_color: " + str(sigmaColor) +
|
||||
# " sigma_spatial: " + str(sigmaSpace) + " channel_axis: " +
|
||||
# str(channelAxis) + " iterations: " + str(iterations))
|
||||
# " sigma_spatial: " + str(sigmaSpace) + " iterations: " + str(iterations))
|
||||
|
||||
for i in range(iterations):
|
||||
self.img = skirest.denoise_bilateral(
|
||||
self.img, sigma_color=sigmaColor,
|
||||
sigma_spatial=sigmaSpace, channel_axis=channelAxis)
|
||||
sigma_spatial=sigmaSpace, channel_axis=None)
|
||||
|
||||
|
||||
class denoise_tv_chambolle(filter):
|
||||
@ -171,16 +175,18 @@ class denoise_tv_chambolle(filter):
|
||||
super().__init__(img)
|
||||
|
||||
def apply(self, params):
|
||||
|
||||
# Denoising weight. The greater weight, the more denoising.
|
||||
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
|
||||
|
||||
#print("with params: weight: " + str(weight) +
|
||||
# " channel_axis: " + str(channelAxis) + " iterations: " + str(iterations))
|
||||
# " iterations: " + str(iterations))
|
||||
for i in range(iterations):
|
||||
self.img = skirest.denoise_tv_chambolle(
|
||||
self.img, weight=weight, channel_axis=channelAxis)
|
||||
self.img, weight=weight, channel_axis=None)
|
||||
|
||||
|
||||
class sharpen(filter):
|
||||
@ -235,6 +241,7 @@ class unsharp_mask_scikit(filter):
|
||||
def apply(self, params):
|
||||
radius = int(params["radius"]) if params["radius"] else 3
|
||||
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"]
|
||||
) if params["channelAxis"] else None
|
||||
|
||||
|
@ -7,15 +7,14 @@
|
||||
import argparse as ap
|
||||
import sys
|
||||
import json
|
||||
import math
|
||||
from os.path import exists
|
||||
|
||||
# Libraries for image processing
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
#from PIL import Image
|
||||
import cv2 as cv
|
||||
from stl import mesh
|
||||
import math
|
||||
|
||||
# Import custom image filter library
|
||||
import filters as flt
|
||||
@ -158,7 +157,7 @@ class app:
|
||||
"ksize", "kernel", "sigmaX", "sigmaY",
|
||||
"sigmaColor", "sigmaSpace", "d", "anchor", "iterations",
|
||||
"op", "strength", "amount", "radius", "weight", "channelAxis",
|
||||
"theta", "sigma", "lambda", "gamma", "psi"}
|
||||
"theta", "sigma", "lambda", "gamma", "psi", "shape"}
|
||||
|
||||
for key in possible_params:
|
||||
if params.get(key) is None:
|
||||
@ -576,7 +575,7 @@ class app:
|
||||
def save_stl(self):
|
||||
'''Save final mesh to stl file.
|
||||
'''
|
||||
|
||||
# TODO: add a hash function to create filename specific to input image and preset
|
||||
if self.mode == "3d":
|
||||
self.mesh_finger.save(self.stl_file)
|
||||
else:
|
||||
|
Reference in New Issue
Block a user