Functions
Edge detection filters

Functions

template<class VOXEL >
void i3d::CompassSobel3D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::EstimateGradient1_3D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out, bool clamp)
template<class VOXEL >
void i3d::EstimateGradient2_3D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out, bool clamp)
void i3d::EstimateGradientMagnitude (const Image3d< float > &in, Image3d< float > &out)
template<class VOXEL >
void i3d::Kirsch3D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::Laplace3D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::MarrHildreth3D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out, double sigma1, double sigma2)
template<class VOXEL >
void i3d::Prewitt3D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::Roberts3D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::Robinson3D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::ShenCastan3D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out, double p, int WinHalfSize)
template<class VOXEL >
void i3d::Sobel3D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::CompassSobel2D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::EstimateGradient1_2D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out, bool clamp)
template<class VOXEL >
void i3d::EstimateGradient2_2D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out, bool clamp)
template<class VOXEL >
void i3d::Kirsch2D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::Laplace2D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::MarrHildreth2D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out, double sigma1, double sigma2)
template<class VOXEL >
void i3d::Prewitt2D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::ShenCastan2D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out, double p, int WinHalfSize)
template<class VOXEL >
void i3d::Sobel2D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::Roberts2D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::Robinson2D (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::hystThres3D (Image3d< VOXEL > &data, unsigned short lowThreshold, unsigned short highThreshold)
template<class VOXEL >
void i3d::hystThres2D (Image3d< VOXEL > &data, unsigned short lowThreshold, unsigned short highThreshold)
template<class VOXEL >
void i3d::Sobel (Image3d< VOXEL > &, bool do_vertical=true, bool do_horizontal=true)
template<class VOXEL >
void i3d::Laplace (const Image3d< VOXEL > &in, Image3d< VOXEL > &out)
template<class VOXEL >
void i3d::SigmaFilter (const Image3d< VOXEL > &in, Image3d< VOXEL > &out, const Neighbourhood &neib, const Neighbourhood &neib1, VOXEL sigma, int tres)

Function Documentation

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::CompassSobel3D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply compass version of 3D Sobel filter on input image in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::EstimateGradient1_3D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out,
bool  clamp 
)

Apply simple 3D edge operator on input image in is input image out is output image clamp - stretch side voxels.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::EstimateGradient2_3D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out,
bool  clamp 
)

Apply simple 3D edge operator on input image in is input image out is output image clamp - stretch side voxels.

I3D_ALGO_EXPORT void i3d::EstimateGradientMagnitude ( const Image3d< float > &  in,
Image3d< float > &  out 
)

Estimate the gradient magnitude of given image using the central difference scheme.

The central differences are substituted with the right or left ones on the image border.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Kirsch3D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 3D Kirsch filter on input image in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Laplace3D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 3D Laplace filter on input image in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::MarrHildreth3D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out,
double  sigma1,
double  sigma2 
)

Apply 3D Marr-Hildreth edge detector on input image This edge detector doesn't respect anisotropic image in is input image out is output image sigma1 is standard deviation of Gauss filter sigma2 is standard deviation of Gauss filter.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Prewitt3D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 3D Prewitt filter on input image in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Roberts3D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 3D Roberts filter on input image in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Robinson3D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 3D Robinson filter on input image in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::ShenCastan3D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out,
double  p,
int  WinHalfSize 
)

Apply 3D Shen-Castan edge detector on input image This edge detector doesn't respect anisotropic image in is input image out is output image p is parameter to ISEF filter WinHalfSize is half-size of window for adaptive gradient function.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Sobel3D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 3D Sobel filter on input image in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::CompassSobel2D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply compass version of 2D Sobel filter on input image separately for each slice in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::EstimateGradient1_2D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out,
bool  clamp 
)

Apply simple 2D edge operator on input image separately for each slice in in is input image out is output image clamp - stretch side voxels.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::EstimateGradient2_2D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out,
bool  clamp 
)

Apply simple 2D edge operator on input image separately for each slice in is input image out is output image clamp - stretch side voxels.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Kirsch2D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 2D Kirsch filter on input image separately for each slice in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Laplace2D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 2D Laplace filter on input image separately for each slice in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::MarrHildreth2D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out,
double  sigma1,
double  sigma2 
)

Apply 2D Marr-Hildreth edge detector on input image separately for each slice This edge detector doesn't respect anisotropic image in is input image out is output image sigma1 is standard deviation of Gauss filter sigma2 is standard deviation of Gauss filter.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Prewitt2D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 2D Prewitt filter on input image separately for each slice in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::ShenCastan2D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out,
double  p,
int  WinHalfSize 
)

Apply 2D Shen-Castan edge detector on input image separately for each slice This edge detector doesn't respect anisotropic image in is input image out is output image p is parameter to ISEF filter WinHalfSize is half-size of window for adaptive gradient function.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Sobel2D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 2D Sobel filter on input image separately for each slice in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Roberts2D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 2D Roberts filter on input image separately for each slice in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::Robinson2D ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Apply 2D Robinson filter on input image separately for each slice in is input image out is output image.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::hystThres3D ( Image3d< VOXEL > &  data,
unsigned short  lowThreshold,
unsigned short  highThreshold 
)

Apply 3D hysteresis threshold on input image data is input image and output image lowThreshold is lower value of threshold highThreshold is higher value of threshold.

template<class VOXEL >
I3D_ALGO_EXPORT void i3d::hystThres2D ( Image3d< VOXEL > &  data,
unsigned short  lowThreshold,
unsigned short  highThreshold 
)

Apply 2D hysteresis threshold on input image separately for each slice data is input image and output image lowThreshold is lower value of threshold highThreshold is higher value of threshold.

template<class VOXEL >
void i3d::Sobel ( Image3d< VOXEL > &  img,
bool  do_vertical = true,
bool  do_horizontal = true 
)

Sobel applies a Sobel (2D edge detector) filter to each slice of an image.

only vertical or only horizontal filtering can be called. if both vertical and horizontal filtering is demanded then the resultant voxel is computed as a length of vector (vertical_result, horizontal_result)

template<class VOXEL >
void i3d::Laplace ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out 
)

Computes image Laplacian.

(it has sense for signed data types only)

template<class VOXEL >
void i3d::SigmaFilter ( const Image3d< VOXEL > &  in,
Image3d< VOXEL > &  out,
const Neighbourhood &  neib,
const Neighbourhood &  neib1,
VOXEL  sigma,
int  tres 
)

This non-linear filter is designed to supress high frequencies in input image and not to blur the sharp and significant edges in the image.

This non-linear filter is designed to supress high frequencies in input image and not to blur the sharp and significant edges in the image. The implementation of this filter is based on the article: Jong-Sen Lee: Digital Image Smoothing and the Sigma Filter, Computer Vision, Graphics and Image processing, volume 24, 255-269, year 1983. The parameters are: in - input image out -- output image neib -- the type of neighbourhood, where the weighted sigma sum should be computed neib1 -- the type of neighbourhood, where the average of immediate neighbours should be computed sigma -- the maximal deviation (it has similar mean as the sigma parameter in classic gaussian). tres -- value of auxilliary treshold.

The Algorithm: For every voxel of the input image: 1) Compute first the tolerance interval $T$: $T = (x_i - sigma, x_i + sigma)$.

2) Compute weighted average of voxel values in the "neib" neighbourhood.

\[WeightedSum = \sum_{x \in AllVoxelsInNeib} ( x * delta_x )\]

\[WeightedDivider = \sum_{x \in AllVoxelsInNeib} (delta_x)\]

\[WeightedAverage = WeightedSum / WeightedDivider\]

where $delta_x = 1 if x \in T$, otherwise $delta_x = 0$.

3)

\[OutputVoxel = WeightedSum if WeightedDivider is > tres\]

else

\[ImmediateNeighborsAverage = \sum_{x \in AllVoxelsInNeib1} x / |{AllVoxelsInNeib1}|\]

\[OutputVoxel = ImmediateNeighborsAverage\]

The Meaning: In steps 1 and 2 of the algorithm we make only better gaussian, We don't compute the average from the voxels, which Intesity value is far from the value of the central voxel of the neighbourhood. This should supress the noise and should not blur the significcant edges. In the fourth step we can supress some hot cluster noise. If the central voxel has the intensity value far from the values of his neighbours (The Weighted_Divider is small number), it is probably member of "hot cluster", so we should save the Immediate_neighbours_Average in the output image rather than the Weighted_average.

The usage: input and output image should be GRAY8, GRAY16 or float. the "neib" parameter is supposed to be the box neighbourhood constructed with function void ConstructBoxNeighbourhood(Neighbourhood nb,double r1, double r2, double r3) (see neighbours.h)

the "neib1" parameter should be the classic constant 4 or 8 neighbourhood in 2D, or 6, 18, or 26 neighbourhood in 3D. (See neighbours.h)

the parameter "sigma" should be relative small (5-20) fo noisy low contrast images. the parameter "tres" shoulb be < 4 for 7x7 neighbourhood in 2D < 3 for 5x5 neighbourhood.

Pretty results can be obtained by iterative use of the filter with constant or growing sigma. (the output of one iteration is the input of next iteration)