DIPlib Documentation - ©1995-2015 Quantitative Imaging Group, Delft University of Technology.

# GeneralisedKuwahara

Generalised Kuwahara filter

## SYNOPSIS

`#include "dip_filtering.h"`

dip_Error dip_GeneralisedKuwahara ( in, selection, out, se, boundary, param, shape, minimum )

## DATA TYPES

binary, integer, float

## FUNCTION

This function is a generalisation of the `Kuwahara` filter in the sense that is does not use the variance criterion to select the smoothed value, but instead accepts an image with the selection values. The algorithm finds, for every pixel, the minimum or maximum (as specified with `minimum`) value of `selection` within the filter window (its size specified by `param`), and outputs the corresponding value in `in`. When `in` is the output of `Uniform`, and `selection` is the output of `VarianceFilter`, this function produces the same result as `Kuwahara`.

Only the rectangular, elliptic and diamond filter shapes are supported (`DIP_FLT_SHAPE_RECTANGULAR`, `DIP_FLT_SHAPE_ELLIPTIC` and `DIP_FLT_SHAPE_DIAMOND`). Other filter shapes can be implemented by setting `shape` to `DIP_FLT_SHAPE_STRUCTURING_ELEMENT`, and passing a binary image in `se`. The "on" pixels define the shape of the filter window. Other values of `shape` are illegal.

If `shape` is not equal to `DIP_FLT_SHAPE_STRUCTURING_ELEMENT`, `se` can be set to zero. When `shape` is set to `DIP_FLT_SHAPE_STRUCTURING_ELEMENT`, `param` is ignored, and can be set to zero.

## ARGUMENTS

Data type | Name | Description
`dip_Image` | `in` | Input
`dip_Image` | `selection` | Selection
`dip_Image` | `out` | Output
`dip_Image` | `se` | Custom filter window (binary)
`dip_BoundaryArray` | `boundary` | Boundary conditions
`dip_FloatArray` | `param` | Filter sizes
`dip_FilterShape` | `shape` | Filter shape
`dip_Boolean` | `minimum` | Select minimum or maximum?

The enumerator `dip_FilterShape` contains the following constants:

Name | Description
`DIP_FLT_SHAPE_DEFAULT` | Default filter window, same as `DIP_FLT_SHAPE_RECTANGULAR`
`DIP_FLT_SHAPE_RECTANGULAR` | Rectangular filter window, can be even in size
`DIP_FLT_SHAPE_ELLIPTIC` | Elliptic filter window, always odd in size
`DIP_FLT_SHAPE_DIAMOND` | Diamond-shaped filter window, always odd in size
`DIP_FLT_SHAPE_PARABOLIC` | Parabolic filter window (morphology only)
`DIP_FLT_SHAPE_DISCRETE_LINE` | Rotated line structuring element (morphology only)
`DIP_FLT_SHAPE_INTERPOLATED_LINE` | Rotated line structuring element, through interpolation (morphology only)
`DIP_FLT_SHAPE_PERIODIC_LINE` | (not implemented)
`DIP_FLT_SHAPE_STRUCTURING_ELEMENT` | Use `se` as filter window, can be any size

## SEE ALSO

`Kuwahara`, `KuwaharaImproved`, `GeneralisedKuwaharaImproved`, `VarianceFilter`, `Uniform`