NPR module¶
Kuwahara filter¶
-
void
lime
::
kuwaharaFilter
(cv::InputArray src, cv::OutputArray dst, int type, int ksize, int nDivide = 0)¶ Apply Kuwahara filter to the image.
Parameters
src: Input image.
dst: Output image.
type: Kuwahara filter type (see
lime::KuwaharaType
).ksize: Kernel size of the filter.
nDivide: # of orientation divisions (not used for
KUWAHARA_CLASSICAL
).
dst = lime.kuwaharaFilter(src, ftype, ksize, ndivide = 0)
Parameters
src -
numpy.ndarray
: The floating-point, 1 or 3-channel image.ftype -
int
: Chosen fromlime::KuwaharaType
.ksize -
int
ndivide -
int
Returnsdst -
numpy.ndarray
: The destination image; will have the same types as src.
Line integral convolution¶
-
void
lime
::
LIC
(cv::InputArray src, cv::OutputArray dst, const cv::Mat &tangent, int L, int licType = LIC_EULERIAN)¶ Integrate the pixel values along flow field.
Parameters
src: The source 8-bit or floating-point, 1-channel or 3-channel image.
dst: The destination image; will have the same size and the same type as src.
tangent: The floating-point, 2-channel image storing tangent directions of pixels.
L: Convolution length.
licType: The algorithm used for the convolution (see
lime::LICType
).
dst = lime.LIC(src, L, lictype = lime.LIC_EULERIAN)
Parameters
src -
numpy.ndarray
: 1 or 3-channel, floating-point image.L -
int
lictype -
int
: Chosen fromlime::LICType
dst -
numpy.ndarray
: The same type with src.
-
enum
lime
::
LICType
¶ LIC algorithm types, which represent methods to generate integration paths.
Values:
-
LIC_CLASSICAL
¶ Slow but outputs beautiful vector fields.
-
LIC_EULERIAN
¶ Fast and stable algorithm.
-
LIC_RUNGE_KUTTA
¶ Second-order line integration.
-
-
void
lime
::
angle2vector
(cv::InputArray angle, cv::OutputArray vfield, double scale = 1.0)¶ Converts flow orientation angle to vector field.
Parameters
angle: The floating-point, 1-channel image storing orientation angle in \([0, 2\pi\)].
vfield: The destination image; will have floating-point, 2-channel normalized vector values.
vfield = np.ndarray((angle.shape[0], angle.shape[1], 2), dtype=np.float32) vfield[:,:,0] = np.cos(angle) * scale vfield[:,:,1] = np.sin(angle) * scale
-
void
lime
::
vector2angle
(cv::InputArray vfield, cv::OutputArray angle)¶ Converts vector field to orientation angles.
Parameters
vfield: The floating-point, 2-channel image storing normalized vector values.
angle: The destiation image; will have floting-point, 1-channel image storing orientation angles.
angle = np.arctan(vfield[:,:,1], vfield[:,:,0])
Morphological filter¶
-
void
lime
::
morphFilter
(cv::InputArray src, cv::OutputArray dst, int type, int ksize)¶ Image filtering with mathematical morphology.
Parameters
src: The floating-point, 1 or 3-channel image.
dst: The destination image; will have the same type as src.
type: The type of morphology operation (see
lime::MorphType
).ksize: Kernel size of the filter.
dst = lime.morphFilter(src, ftype, ksize)
Parameters
src -
numpy.ndarray
: The floating-point, 1 or 3-channel image.ftype -
int
: Chosen fromlime::MorphType
.ksize -
int
: Kernel size.
dst -
numpy.ndarray
: The destination image with the same type as src.
-
enum
lime
::
MorphType
¶ Morphological filter types.
Values:
-
MORPH_ERODE
¶ Erosion.
-
MORPH_DILATE
¶ Dilation.
-
MORPH_OPEN
¶ Opening = \( Erosion \rightarrow Dilation \).
-
MORPH_CLOSE
¶ Closing = \( Dilation \rightarrow Erosion \).
-
MORPH_GRADIENT
¶ Gradient = \( Dilation - Erosion \).
-
MORPH_TOPHAT
¶ Top-hat = \( Input - Opening \).
-
MORPH_BLACKHAT
¶ Black-hat = \( Input - Closing \).
-
Noise pattern¶
-
void
lime
::
randomNoise
(cv::OutputArray noise, const cv::Size &size)¶ Generate random noise.
Each pixel value takes random number between \([0, 1]\).
Parameters
noise: Generated noise image; will have floating-point, 1-channel pixel values.
size: Size of the noise image.
noise = lime.randomNoise(size)
Parameters
size -
tuple
ofint
: Noise image size.
noise -
numpy.ndarray
: The floating-point, 1-channel noise image.
-
void
lime
::
perlinNoise
(cv::OutputArray noise, const cv::Size &size, int level)¶ Generate Perlin noise.
Parameters
noise: Generated noise image; will have floating-point, 1-channel pixel values.
size: Size of the noise image.
level: Maximum depth level used to generate the Perlin noise.
noise = lime.perlinNoise(size, level)
Parameters
size -
tuple
ofint
: Noise image size.level -
int
noise -
numpy.ndarray
: The floating-point, 1-channel noise image.
NPR edges¶
-
void
lime
::
edgeDoG
(cv::InputArray image, cv::OutputArray edge, const DoGParams ¶ms = DoGParams())¶ Detecting NPR edges with DoG filter.
Parameters
image: The input floating-point, 1-channel image.
edge: The floating-point, 1-channel edge image.
params: DoG parameters.
edge = lime.edgeDoG(image, params = {})
Parameters
image -
numpy.ndarray
: The input floating-point, 1-channel image.params -
dict
: Stores the pair of parameter names and corresponding values.
edge -
numpy.ndarray
: The floating-point, 1-channel edge image.
-
struct
DoGParams
¶ DoG parameters.
Public Functions
-
LIME_METHOD_API
DoGParams
(double kappa = 4.5, double sigma = 0.5, double tau = 0.95, double phi = 10.0, NPREdgeType edgeType = NPR_EDGE_XDOG)¶ Constructor.
-
LIME_METHOD_API
PDE-based filter¶
-
void
lime
::
pdeFilter
(cv::InputArray src, cv::OutputArray dst, int type, double lambda, int maxiter)¶ Apply PDE-based filtering (PDE = pertial differential equation).
Parameters
src: The input floating-point, 1 or 3-channel image.
dst: The destination image; will have the save type as src.
type: Filter type (see
lime::PDEType
).lambda: Filter strength for one iteration.
maxiter: # of iteration for solving the PDE.
# Python dst = lime.pdeFilter(src, ftype, lambda, maxiter)
Parameters
src -
numpy.ndarray
: The floating-point, 1 or 3-channel image.ftype -
int
: Filter type (seelime::PDEType
).lamdba -
double
maxiter -
int
dst -
numpy.ndarray
: The destination image with the same type as src.
Vector field detection¶
-
void
lime
::
calcVectorField
(cv::InputArray input, cv::OutputArray angles, int ksize = 5, int vfieldType = VEC_FIELD_SST, int edgeDetector = EDGE_DETECT_SOBEL)¶ Compute smooth edge flow field from the input image.
Parameters
img: The input 8-bit integer or floating-point, 1 or 3-channel image.
angles: The destination vector field; will have floating-point, 1-channel orientation angles.
ksize: Kernel size for smoothing the vector field
vfieldType: Algorithm to detect vector field (see
lime::VecFieldType
).edgeDetector: Edge detection algorithm (see
lime::EdgeDetector
).
angles = lime.calcVectorField(img, ksize = 5, vftype = lime.VEC_FIELD_SST, edtype = lime.EDGE_DETECT_SOBEL)
Parameters
img -
numpy.ndarray
ksize -
int
vftype -
int
: Chosen fromlime::VecFieldType
.edtype -
int
: Chosen fromlime::EdgeDetector
.