CIB image toolbox technical manual

6. Image processing algorithms: Filters

6.2. Binarization filters

The following chapters explain each filter. Usually there is also an example given. The input image for the filters is the following picture:


COCOCLUST_Binarizer
FBCITB_Binarizer
FengBinarizerFilter
GaussianBlurFilter
LocalOtsuBinarizer
MedianBlurAGTFilter
MedianBlurATFilter
MedianBlurGATFilter
NativeAdaptiveBinarizer
NiblackBinarizerFilter
NICKBinarizerFilter
OtsuBinarizer
PureAdaptiveGaussianThresholdingFilter
PureAdaptiveThresholdingFilter
SauvolaBinarizerFilter
ThresholdFilter
WolfJolionBinarizerFilter

COCOCLUST_Binarizer

Parameters:

Threshold:45|CLAHEClipLimit:3.0|GaussianBlurKernelSize:19|CannyUpperThresholdCoeff:0.15

Output:



Implementation of COCOCLUST binarization.

This binarizator is described in the publication Kasar, T. and Ramakrishnan, A.G., 2009. COCOCLUST: Contour-based color clustering for robust binarization of colored text. Proc. The Third CBDAR, pp.11-17.

Parameters of this filter can be described in profile:

<ProcessingProfile>
... <COCOCLUST_Binarizer>  <Threshold>45</Threshold>    <CLAHEClipLimit>3.0</CLAHEClipLimit>   <GaussianBlurKernelSize>19</GaussianBlurKernelSize>  <CannyUpperThresholdCoeff>0.15</CannyUpperThresholdCoeff>  <CannyLowerThresholdCoeff>0.05</CannyLowerThresholdCoeff>  <CannyMorphIters>4</CannyMorphIters> </COCOCLUST_Binarizer>
...
</ProcessingProfile>

Property name

Description

Default value

Threshold

Threshold for preliminary clustering procedure

45

CLAHEClipLimit

Parameter for CLAHE procedure

3.0

GaussianBlurKernelSize

Parameter for Gaussian blur procedure

19

CannyUpperThresholdCoeff

Coefficient for upper threshold of Canny edge detector

0.15

CannyLowerThresholdCoeff

Coefficient for lower threshold of Canny edge detector

0.05

CannyMorphIters

Parameter of morphology operations

4



FBCITB_Binarizer

Parameters:

UseCanny:1|UseVariancesMap:1

Output:



Implementation of FBCITB binarization.

This binarizator is described in Kasar, T., Kumar, J. and Ramakrishnan, A.G., 2007, September. Font and background color independent text binarization. In Second international workshop on camera-based document analysis and recognition (pp. 3-9).

Parameters of this filter can be described in profile:

<ProcessingProfile>
... <FBCITB_Binarizer>   <UseCanny>1</UseCanny>   <UseVariancesMap>0</UseVariancesMap>  <VarianceMapThreshold>200</VarianceMapThreshold>  <CLAHEClipLimit>2.0</CLAHEClipLimit>   <GaussianBlurKernelSize>9</GaussianBlurKernelSize>    <CannyUpperThresholdCoeff>0.6</CannyUpperThresholdCoeff>   <CannyLowerThresholdCoeff>0.4</CannyLowerThresholdCoeff>   <BoundingRectangleMaxArea>0.3</BoundingRectangleMaxArea> </FBCITB_Binarizer>
...
</ProcessingProfile>

Property name

Description

Default value

UseCanny

Is not equal 0 if Canny border detection is required

1

UseVariancesMap

Is not equal 0 variances map is used for contour detection

0

VarianceMapThreshold

Variance threshold

200

CLAHEClipLimit

Parameter for CLAHE procedure

2.0

GaussianBlurKernelSize

Parameter for Gaussian blur procedure

9

CannyUpperThresholdCoeff

Coefficient for upper threshold of Canny edge detector

0.6

CannyLowerThresholdCoeff

Coefficient for lower threshold of Canny edge detector

0.4

BoundingRectangleMaxArea

Coefficient for the bounding rectangle area

0.3


FengBinarizerFilter

Parameters:

WindowSize:21|Alpha1:0.7|k1:0.2|k2:0.03|Gamma:2.0|MorphIterationCount:2

Output:



Implementation of Feng binarization.

This binarizator is described in Khurshid, K., Siddiqi, I., Faure, C. and Vincent, N., 2009, January. Comparison of Niblack inspired binarization methods for ancient documents. In Document Recognition and Retrieval XVI (Vol. 7247, p. 72470U). International Society for Optics and Photonics.

Parameters of this filter can be described in profile:

<ProcessingProfile>
... <FengBinarizerFilter> <WindowSize>21</WindowSize>
 <Alpha1>0.7</Alpha1>
 <k1>0.2</k1>
 <k2>0.03</k2>
 <Gamma>2.0</Gamma>
 <MorphIterationCount>2</MorphIterationCount> </FengBinarizerFilter>
...
</ProcessingProfile>

Property name

Description

Default value

WindowSize

Size of sliding window

21

Alpha1

Coefficient for threshold calculation

0.7

k1

Coefficient for threshold calculation

0.2

k2

Coefficient for threshold calculation

0.03

Gamma

Coefficient for threshold calculation

2.0

MorphIterationCount

Count of iterations of final dilate and erode operations

2

 


GaussianBlurFilter

In image processing, a Gaussian blur is the result of blurring an image by a Gaussian function. This function used to reduce Image noise and detail.

 

Parameters of this filter can be described in profile:

Please note that “KernelSize” only accept odd numbers!

<?xml version="1.0" encoding="utf-8"?>
<algorithms>
<algorithm name="ImageManipulation" TracingEnabled="false" inputs="in1=$1" outputs="out4=$1">
<layer>
<processor params="KernelSize:21" type="GaussianBlurFilter" outputs="out4" inputs="in1" />
</layer>
</algorithm>
</algorithms>  


LocalOtsuBinarizer

Parameters:

CLAHEClipLimit:0.0|GaussianBlurKernelSize:19|CannyUpperThresholdCoeff:0.15|CannyLowerThresholdCoeff:0.01|MaxValue:255.0|CannyMorphIters:1

Output:


Implementation of Otsu binarization algorithm.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <LocalOtsuBinarizer> <MaxValue>255.0</MaxValue> <CLAHEClipLimit>0.0</CLAHEClipLimit>  <GaussianBlurKernelSize>19</GaussianBlurKernelSize>   <CannyUpperThresholdCoeff>0.15</CannyUpperThresholdCoeff> <CannyLowerThresholdCoeff>0.01</CannyLowerThresholdCoeff>   <CannyMorphIters>1</CannyMorphIters> </LocalOtsuBinarizer>
...
</ProcessingProfile>

Property name

Description

Default value

MaxValue

Maximal value

255.0

CLAHEClipLimit

Parameter for CLAHE procedure

0.0

GaussianBlurKernelSize

Parameter for Gaussian blur procedure

19

CannyUpperThresholdCoeff

Coefficient for upper threshold of Canny edge detector

0.15

CannyLowerThresholdCoeff

Coefficient for lower threshold of Canny edge detector

0.01

CannyMorphIters

Parameter of morphology operations

1


MedianBlurAGTFilter

Parameters:

KernelSize:3|BlockSize:5|Shift:0.0|MaxValue:255.0

Output:


Median blur + Adaptive Gaussian threshold filter.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <MedianBlurAGTFilter> <KernelSize>3</KernelSize>   <MaxValue>255.0</MaxValue>  <BlockSize>5</BlockSize> <Shift>0.0</Shift>
 </MedianBlurAGTFilter>
...
</ProcessingProfile>

Property name

Description

Default value

KernelSize

Size of kernel of median blur filter

3

BlockSize

Size of sliding window

5

Shift

Constant subtracted from the mean or weighted mean

0.0

MaxValue

Color of background of binarized image

255.0


MedianBlurATFilter

Parameters:

KernelSize:3|BlockSize:5|Shift:0.0|MaxValue:255.0

Output:


Median blur + Adaptive threshold filter.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <MedianBlurATFilter>   <KernelSize>3</KernelSize> <MaxValue>255.0</MaxValue>  <BlockSize>5</BlockSize>  <Shift>0.0</Shift>
 </MedianBlurATFilter>
...
</ProcessingProfile>

Property name

Description

Default value

KernelSize

Size of kernel of median blur filter

3

BlockSize

Size of sliding window

5

Shift

Constant subtracted from the mean or weighted mean

0.0

MaxValue

Color of background of binarized image

255.0



MedianBlurGATFilter

Parameters:

Default Parameters

Output:


Gaussian blur + Adaptive threshold filter.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <MedianBlurGATFilter>
  <KernelSize>3</KernelSize>
  <SigmaX>10.0</SigmaX>
  <SigmaY>0.0</SigmaY> <MaxValue>255.0</MaxValue> <BlockSize>5</BlockSize> <Shift>0.0</Shift>
 </MedianBlurGATFilter>
...
</ProcessingProfile>

Property name

Description

Default value

KernelSize

Size of kernel of median blur filter

3

SigmaX

Sigma for horizontal direction

10.0

SigmaY

Sigma for vertical direction

0.0

MaxValue

Color of background of binarized image

255.0

BlockSize

Size of sliding window

5

Shift

Constant subtracted from the mean or weighted mean

0.0


NativeAdaptiveBinarizer

Parameters:

Default Parameters

Output:


Native adaptive thresholding.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <NativeAdaptiveBinarizer>   <IsGaussianBlurReqiured>0</IsGaussianBlurReqiured>  <MedianBlurKernelSize>5</MedianBlurKernelSize> <GaussianBlurKernelSize>3</GaussianBlurKernelSize>
  <GaussianBlurSigma>150</GaussianBlurSigma <IsAdaptiveThresholdCalculatedByGaussian>1</IsAdaptiveThresholdCalculatedByGaussian> <AdaptiveThresholdingMaxValue>255.0</AdaptiveThresholdingMaxValue> <AdaptiveThresholdingBlockSize>19</AdaptiveThresholdingBlockSize> <AdaptiveThresholdingShift>8</AdaptiveThresholdingShift> <BilateralFilterBlockSize>5</BilateralFilterBlockSize> <BilateralFilterColorSigma>50.0</BilateralFilterColorSigma> <BilateralFilterSpaceSigma>50.0</BilateralFilterSpaceSigma>
 </NativeAdaptiveBinarizer>
...
</ProcessingProfile>

Property name

Description

Default value

IsGaussianBlurReqiured

Flag of usage Gaussian blur

0

MedianBlurKernelSize

Kernel size for median blur

5

GaussianBlurKernelSize

Kernel size for Gaussian blur

3

GaussianBlurSigma

Gaussian blur sigma

150

IsAdaptiveThresholdCalculatedByGaussian

Flag of base of adaptive thresholding type

1

AdaptiveThresholdingMaxValue

New value for pixel which intensity greater than threshold value

255.0

AdaptiveThresholdingBlockSize

Kernel size for adaptive thresholding procedure

19

AdaptiveThresholdingShift

Shifting value for adaptive thresholding procedure

8

BilateralFilterBlockSize

Kernel size for bilateral filtration. If less than 0 then filtration isn't used

5

BilateralFilterColorSigma

Sigma for intensity range

50.0

BilateralFilterSpaceSigma

Sigma for space range

50.0


NiblackBinarizerFilter

Parameters:

WindowSize:101|ThresholdCoefficient:0.01|MorphIterationCount:2

Output:


Implementation of Niblack binarization.

This binarizator is described in Khurshid, K., Siddiqi, I., Faure, C. and Vincent, N., 2009, January. Comparison of Niblack inspired binarization methods for ancient documents. In Document Recognition and Retrieval XVI (Vol. 7247, p. 72470U). International Society for Optics and Photonics.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
  <NiblackBinarizerFilter>   <WindowSize>101</WindowSize>  <ThresholdCoefficient>0.01</ThresholdCoefficient>  <MorphIterationCount>2</MorphIterationCount> </NiblackBinarizerFilter>
...
</ProcessingProfile>

Property name

Description

Default value

WindowSize

Size of sliding window

101

ThresholdCoefficient

Coefficient $k$ for threshold calculation

0.01

MorphIterationCount

Count of iterations of final dilate and erode operations

2


NICKBinarizerFilter

Parameters:

WindowSize:101|ThresholdCoefficient:0.01|MorphIterationCount:2

Output:


Implementation of NICK binarization.

This binarizator is described in Khurshid, K., Siddiqi, I., Faure, C. and Vincent, N., 2009, January. Comparison of Niblack inspired binarization methods for ancient documents. In Document Recognition and Retrieval XVI (Vol. 7247, p. 72470U). International Society for Optics and Photonics.

Parameters of this filter can be described in profile:

<ProcessingProfile>
... <NICKBinarizerFilter>   <WindowSize>101</WindowSize>   <ThresholdCoefficient>0.01</ThresholdCoefficient> <MorphIterationCount>2</MorphIterationCount> </NICKBinarizerFilter>
...
</ProcessingProfile>

Property name

Description

Default value

WindowSize

Size of sliding window

101

ThresholdCoefficient

Coefficient $k$ for threshold calculation

0.01

MorphIterationCount

Count of iterations of final dilate and erode operations

2


OtsuBinarizer

Parameters:

MaxValue:255

Output:


Interface for Otsu binarization algorithm.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <OtsuBinarizer>  <MaxValue>255.0</MaxValue>
  </OtsuBinarizer>
...
</ProcessingProfile>

Property name

Description

Default value

MaxValue

Color of background of binarized image

255.0


PureAdaptiveGaussianThresholdingFilter

Parameters:

MaxValue:255|BlockSize:5|Shift:0.0

Output:


Pure adaptive Gaussian thresholding filter.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <PureAdaptiveGaussianThresholdingFilter> 
<MaxValue>255.0</MaxValue>
<BlockSize>5</BlockSize> 
<Shift>0.0</Shift>
 </PureAdaptiveGaussianThresholdingFilter>
...
</ProcessingProfile>

Property name

Description

Default value

MaxValue

Color of background of binarized image

255.0

BlockSize

Size of sliding window

5

Shift

Constant subtracted from the mean or weighted mean

0.0


PureAdaptiveThresholdingFilter

Parameters:

MaxValue:255|BlockSize:5|Shift:0.0

Output:


Pure adaptive thresholding filter.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <PureAdaptiveThresholdingFilter>  <MaxValue>255.0</MaxValue> <BlockSize>5</BlockSize> <Shift>0.0</Shift>
 </PureAdaptiveThresholdingFilter>
...
</ProcessingProfile>

Property name

Description

Default value

MaxValue

Color of background of binarized image

255.0

BlockSize

Size of sliding window

5

Shift

Constant subtracted from the mean or weighted mean

0.0



SauvolaBinarizerFilter

Parameters:

WindowSize:101|ThresholdCoefficient:0.00|MorphIterationCount:2

Output:


Implementation of Sauvola binarization.

This binarizator is described in Shafait, F., Keysers, D. and Breuel, T.M., 2008, January. Efficient implementation of local adaptive thresholding techniques using integral images. In Document recognition and retrieval XV (Vol. 6815, p. 681510). International Society for Optics and Photonics.

Parameters of this filter can be described in profile:

<ProcessingProfile>
... <SauvolaBinarizerFilter>  <WindowSize>101</WindowSize>   <ThresholdCoefficient>0.01</ThresholdCoefficient> <MorphIterationCount>2</MorphIterationCount> </SauvolaBinarizerFilter>
...
</ProcessingProfile>

Property name

Description

Default value

WindowSize

Size of sliding window

101

ThresholdCoefficient

Coefficient for threshold calculation

0.01

MorphIterationCount

Count of iterations of final dilate and erode operations

2


ThresholdFilter

Parameters:

ThresholdValues:100;128;90

Output:


Pure thresholding binarizator.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
 <ThresholdFilter>
    <ThresholdValues>100;128;90</ThresholdValues>
 </ThresholdFilter>
...
</ProcessingProfile>

Property name

Description

Default value

ThresholdValues

Values of threshold for each color channel

100; 128; 90

Also we can define equal value of thresholds for each channel:

<ProcessingProfile>

...

 <ThresholdFilter>

    <ThresholdValues>128</ThresholdValues>

 </ThresholdFilter>

...

</ProcessingProfile>


WolfJolionBinarizerFilter

Parameters:

WindowSize:101|ThresholdCoefficient:0.00|MorphIterationCount:2

Output:



Implementation of WolfJolion binarization.

This binarizator is described in Khurshid, K., Siddiqi, I., Faure, C. and Vincent, N., 2009, January. Comparison of Niblack inspired binarization methods for ancient documents. In Document Recognition and Retrieval XVI (Vol. 7247, p. 72470U). International Society for Optics and Photonics.

Parameters of this filter can be described in profile:

<ProcessingProfile>
...
  <WolfJolionBinarizerFilter>  <WindowSize>101</WindowSize>  <ThresholdCoefficient>0.01</ThresholdCoefficient> <MorphIterationCount>2</MorphIterationCount> </WolfJolionBinarizerFilter>
...
</ProcessingProfile>

Property name

Description

Default value

WindowSize

Size of sliding window

101

ThresholdCoefficient

Coefficient for threshold calculation

0.01

MorphIterationCount

Count of iterations of final dilate and erode operations

2