CIB image toolbox technical manual

6. Image processing algorithms: Filters

6.3. Modification filters

AlphaMaskFilter
AutoInvertFilter
CleanBackgroundToWhiteFilter
CloseFilter
ColorRangesFilter
ColorSpaceConvertionFilter
ContrastEnhancementFilter
DilateFilter
ErodeFilter
GuoHallThinningFilter
HistogramEqualizationFilter
InvertFilter
OpenFilter
ZhangSuenThinningFilter
ColorRangeConverter
BalanceWhiteFilter
ColorBalanceFilter
ColorSwapFilter

AlphaMaskFilter

Filter for alpha channel thresholding.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <AlphaMaskFilter> <Threshold>128</Threshold> <IsInvertedMaskRequired>0</IsInvertedMaskRequired>  <IsBinaryMaskRequired>1</IsBinaryMaskRequired>
</AlphaMaskFilter>
...
</ProcessingProfile>

 

Property name

Description

Default value

Threshold

Threshold value for applying

128

IsInvertedMaskRequired

If it is not equal 0 then obtained mask should be inverted

0

IsBinaryMaskRequired

– If it is not equal 0 then obtained mask should be binary image else – halftone

1


AutoInvertFilter

Parameters:

Output:


Implementation of auto inversion procedure.

Image will be inverted if a number of non-black point is greater or equal than half of image area.

This filter have no parameters.


CleanBackgroundToWhiteFilter

Parameters:

gamma:1.0|blackValue:70|whiteValue:170

Output:


The filter cleans background with making all near-white colors true white color.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <CleanBackgroundToWhiteFilter> <gamma>1.0</gamma> <blackValue>70</blackValue> <whiteValue>170</whiteValue>
 </CleanBackgroundToWhiteFilter>
...
</ProcessingProfile>

Property name

Description

Default value

gamma

Gamma value

1.0

blackValue

Set black value threshold for the algorithm

70

whiteValue

Set white value threshold for the algorithm binary image else – halftone

170


CloseFilter

Parameters:

IterationCount:2

Output:


Morphology operation 'Close'.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <CloseFilter>   <IterationCount>1</IterationCount>
  </CloseFilter>
...
</ProcessingProfile>

Property name

Description

Default value

IterationCount

Number of iteration of procedure

1


ColorRangesFilter

Parameters:

<default Parameters>

Output:


Interface for color ranges filter.

This filter allows to extract from image all pixels with colors that fall within user defined ranges (or if it is required pixel that do not fall within these ranges). These ranges can be defined by definition of lower and upper range boundary:

<ProcessingProfile>
...
  <ColorRangesFilter> <IsMaskOnlyRequired>0</IsMaskOnlyRequired>
 <IsInRangeColorsRequired>0</IsInRangeColorsRequired>  <LowerBoundaries>0,0,0;130,55,80</LowerBoundaries> <UpperBoundaries>128,128,128;209,190,190</UpperBoundaries> <RangeShapes>b(0, 0, 0, 127, 127, 127)</RangeShapes> </ColorRangesFilter>
...
</ProcessingProfile>

Color ranges can be defined in two ways:

  • by color values boundaries (LowerBoundaries and UpperBoundaries options)
  • by definition of shapes in colorspace (RangeShapes option; this option has higher priority).

For color values boundaries usage we should define lower and upper values of color for each color range:

<LowerBoundaries>R1_L,G1_L,B1_L;R2_L,G2_L,B2_L</LowerBoundaries>
<UpperBoundaries>R1_U,G1_U,B1_U;R2_U,G2_U,B2_U</UpperBoundaries>

where R1_L – lower boundary of red color for the first range, R1_U – upper boundary of red color for the first range.

The same results can be obtained using the second way: we can define corresponding boxes (rectangular shapes):

<RangeShapes>b(R1_L,G1_L,B1_L, R1_U,G1_U,B1_U);b(R2_L,G2_L,B2_L, R2_U,G2_U,B2_U)</RangeShapes>

Also spherical shapes can be used:

<RangeShapes>s(centerR, centerG, centerB, diameter)</RangeShapes>

There is special way for spherical shapes usage: we can use set of spheres to definition of extensional areas. For example, if we have following spheres set:

<RangeShapes>s{(5, 5, 5, 30) - (50, 50, 50, 40) - (100, 100, 50, 50) - (100, 100, 200, 25) - (200, 100, 50, 25)}</RangeShapes>

then we will obtain next 3D area for color selection (intermediate spheres parameters would be calculated automatically).

If IsMaskOnlyRequired is not equal 0 then we obtain only binary mask for defined color ranges.


ColorSpaceConvertionFilter

Parameters:

TargetColorspace:HSV|SourceColorspace:RGB

Output:


Interface of image color space convertion procedure.

This filter can be used for transforming current color space of image (this information can be obtained from input image) to user defined color space.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <ColorSpaceConvertionFilter> <TargetColorspace>HSV</TargetColorspace> <SourceColorspace>RGB</SourceColorspace>
 </ColorSpaceConvertionFilter>
...
</ProcessingProfile>

Property name

Description

Default value

TargetColorspace

required color space

 

SourceColorspace

color space of source image

 

 

Currently implemented next conversions are:

  • RGB -> GRAY
  • RGB -> BGR
  • RGB -> HSV
  • RGB -> HLS
  • RGB -> Lab
  • RGB -> Luv
  • RGB -> XYZ
  • RGB -> YUV
  • RGB -> YCrCb
  • GRAY -> RGB
  • BGR -> RGB
  • HSV -> RGB
  • HLS -> RGB
  • Lab -> RGB
  • Luv -> RGB
  • XYZ -> RGB
  • YUV -> RGB
  • YCrCb -> RGB


ContrastEnhancementFilter

Parameters:

CLAHEClipLimit:2.0

Output:


Contrast enhancement by CLAHE algorithm.

This filter enhance local contrast of image using algorithm CLAHE.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <ContrastEnhancementFilter> <CLAHEClipLimit>2.0</CLAHEClipLimit>
  </ContrastEnhancementFilter>
...
</ProcessingProfile>

Property name

Description

Default value

CLAHEClipLimit

Parameter of local contrast enhancement procedure

2.0


DilateFilter


Parameters:

IterationCount:3

Output:


Morphology operation 'Dilate'.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <DilateFilter> <IterationCount>1</IterationCount>
 </DilateFilter>
...
</ProcessingProfile>

Property name

Description

Default value

IterationCount

Number of iteration of procedure

1


ErodeFilter

Parameters:

IterationCount:1

Output:


Morphology operation 'Erode'.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <ErodeFilter> <IterationCount>1</IterationCount>
 </ErodeFilter>
...
</ProcessingProfile>

Property name

Description

Default value

IterationCount

Number of iteration of procedure

1


GuoHallThinningFilter

Interface for thinning a binary image using Guo-Hall algorithm.

In details this algorithm is described in Kumar, H. and Kaur, P., 2011. A comparative study of iterative thinning algorithms for BMP images. International journal of computer Science and information Technologies (IJCSIT).

This filter has no parameters.


HistogramEqualizationFilter

This filter normalizes the image brightness and contrast by normalizing its histogram.

This filter have no parameters.


InvertFilter

Example

Parameters:

Input:

Output:

Interface for image color inversion.
This filter has no parameters.

OpenFilter

Example

Parameters:
IterationCount:1

Input: (zoomed in)

Output: (zoomed in)

Morphology operation 'Open'.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <OpenFilter> <IterationCount>1</IterationCount>
 </OpenFilter>
...
</ProcessingProfile>

Property name

Description

Default value

IterationCount

Number of iteration of procedure

1


ZhangSuenThinningFilter

Example

Parameters:

Input:

Output:


Interface for thinning a binary image using Zhang-Suen algorithm.

In details this algorithm is described in Kumar, H. and Kaur, P., 2011. A comparative study of iterative thinning algorithms for BMP images. International journal of computer Science and information Technologies (IJCSIT).

This filter has no parameters.


ColorRangeConverter

Converts the color range of the image.

This filter creates the new image using the equation:

dst(x,y) = src(x,y) * Multiplier + Shift

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <ColorRangeConverter> <Multiplier>1.0</Multiplier>  <Shift>0.0</Shift>
 </ColorRangeConverter>
...
</ProcessingProfile>

Property name

Description

Default value

Multiplier

Multiplier (see eq.)

1.0

Shift

Shift (see eq.)

0.0


BalanceWhiteFilter

Filter for white balance correction.

Equation that describes the output image:

dst(x,y) = WhiteBalance(src(x,y)) * Multiplier + Shift

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <BalanceWhiteFilter> <SaturationThreshold>0.9</SaturationThreshold> <Multiplier>1.8</Multiplier> <Shift>0.0</Shift>
 </BalanceWhiteFilter>
...
</ProcessingProfile>

Property name

Description

Default value

SaturationThreshold

Saturation threshold

0.9

Multiplier

Multiplier (see eq.)

1.8

Shift

Shift (see eq.)

0.0


ColorBalanceFilter

Filter for color balance correction.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <BalanceWhiteFilter> <ColorBalanceGamma>1.0</ColorBalanceGamma> <SaturationGamma>1.0</SaturationGamma>
 </BalanceWhiteFilter>
...
</ProcessingProfile>

Property name

Description

Default value

ColorBalanceGamma

Color balance, less than 1 for warm colors, greater than 1 for cold colors. Range (0, 2). Limits are excluded.

1.0

SaturationGamma

Saturation coefficient. Range (0, 2). Limits are excluded.

1.0


ColorSwapFilter

Filter for color channels swap.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <ColorSwapFilter>  <SwapPercent>1</SwapPercent> <SwappedChannels>RB</SwappedChannels>
 </ColorSwapFilter>
...
</ProcessingProfile>

Property name

Description

Default value

SwapPercent

Percent of swapping. Range [1 .. 100]

1

SwappedChannels

Swapped channels brief names. For example, “RB” for R <-> B channel swapping.

RB