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).

Python

dst = lime.kuwaharaFilter(src, ftype, ksize, ndivide = 0)

Parameters

  • src - numpy.ndarray : The floating-point, 1 or 3-channel image.

  • ftype - int : Chosen from lime::KuwaharaType .

  • ksize - int

  • ndivide - int Returns

  • dst - numpy.ndarray : The destination image; will have the same types as src.

enum lime::KuwaharaType

Kuwahara filter types.

Values:

KUWAHARA_CLASSICAL

Classical Kuwahara filter.

KUWAHARA_GENERALIZED

Generalized Kuwahara filter.

KUWAHARA_ANISOTROPIC

Anisotropic Kuwahara filter.

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 ).

Python

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 from lime::LICType

Returns
  • 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.

Python This method is equivalent to following.

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.

Python This method is equivalent to following.

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.

Python

dst = lime.morphFilter(src, ftype, ksize)

Parameters

  • src - numpy.ndarray : The floating-point, 1 or 3-channel image.

  • ftype - int : Chosen from lime::MorphType .

  • ksize - int : Kernel size.

Returns
  • 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.

Python

noise = lime.randomNoise(size)

Parameters

  • size - tuple of int : Noise image size.

Returns
  • 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.

Python

noise = lime.perlinNoise(size, level)

Parameters

  • size - tuple of int : Noise image size.

  • level - int

Returns
  • noise - numpy.ndarray : The floating-point, 1-channel noise image.

NPR edges

void lime::edgeDoG(cv::InputArray image, cv::OutputArray edge, const DoGParams &params = 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.

Returns
  • 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.

enum lime::NPREdgeType

NPR edge types.

Values:

NPR_EDGE_XDOG

Extended DoG (XDoG) filter.

NPR_EDGE_FDOG

Flow DoG (FDoG) filter.

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

# Python
dst = lime.pdeFilter(src, ftype, lambda, maxiter)

Parameters

  • src - numpy.ndarray : The floating-point, 1 or 3-channel image.

  • ftype - int : Filter type (see lime::PDEType ).

  • lamdba - double

  • maxiter - int

Returns
  • dst - numpy.ndarray : The destination image with the same type as src.

enum lime::PDEType

PDE-based filter types.

Values:

PDE_ANISO_DIFFUSION

Anisotropic diffusion.

PDE_SHOCK_FILTER

Shock filter.

PDE_MEAN_CURVATURE

Mean curvature flow.

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 ).

Python

angles = lime.calcVectorField(img, ksize = 5, vftype = lime.VEC_FIELD_SST, edtype = lime.EDGE_DETECT_SOBEL)

Parameters

enum lime::VecFieldType

Vector field types.

Values:

VEC_FIELD_SST

Smoothed structural tensor.

VEC_FIELD_ETF

Edge tangent filter.

enum lime::EdgeDetector

Edge detector types.

Values:

EDGE_DETECT_SOBEL

Sobel filter.

EDGE_DETECT_ROTATIONAL

Rotationally invariant edge detector.