libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Functions
Gray images
+ Collaboration diagram for Gray images:

Classes

class  crn::Gray2BW
 Binarization action. More...
 
class  crn::Gray2BWThreshold
 Threshold binarization action. More...
 
class  crn::Gray2BWNiblack
 Niblack binarization action. More...
 
class  crn::Gray2BWSauvola
 Sauvola binarization action. More...
 
class  crn::Gray2BWkMeansHisto
 k-means histo binarization action More...
 
class  crn::Gray2BWLocalMin
 Local min binarization action. More...
 
class  crn::Gray2BWLocalMax
 Local max binarization action. More...
 
class  crn::Gray2BWFisher
 Fisher binarization action. More...
 
class  crn::Gray2BWEntropy
 Entropy binarization action. More...
 
class  crn::Gray2BWOtsu
 Otsu binarization action. More...
 
struct  crn::IsSerializable< Gray2BW >
 
struct  crn::IsSerializable< Gray2BWThreshold >
 
struct  crn::IsSerializable< Gray2BWNiblack >
 
struct  crn::IsSerializable< Gray2BWSauvola >
 
struct  crn::IsSerializable< Gray2BWkMeansHisto >
 
struct  crn::IsSerializable< Gray2BWLocalMin >
 
struct  crn::IsSerializable< Gray2BWLocalMax >
 
struct  crn::IsSerializable< Gray2BWFisher >
 
struct  crn::IsSerializable< Gray2BWEntropy >
 
struct  crn::IsSerializable< Gray2BWOtsu >
 

Typedefs

using crn::ImageGray = Image< uint8_t >
 Grayscale image class. More...
 
using crn::ImageIntGray = Image< int >
 Int grayscale image class. More...
 
using crn::ImageDoubleGray = Image< double >
 double Grayscale image class More...
 

Functions

void crn::Sqrt (ImageDoubleGray &img) noexcept
 Replaces the pixels with their square root. More...
 
template<typename T >
void crn::Abs (Image< T > &img, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr) noexcept
 Replaces each pixel by its absolute value. More...
 
void crn::AutoContrast (ImageGray &img)
 
template<typename T >
Histogram crn::MakeHistogram (const Image< T > &img, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
Histogram crn::MakeHistogram (const ImageGray &img)
 Creates an histogram from the pixels. More...
 
Histogram crn::HorizontalProjection (const ImageGray &img)
 Computes the horizontal projection. More...
 
Histogram crn::VerticalProjection (const ImageGray &img)
 Computes the vertical projection. More...
 
template<typename T >
size_t crn::StrokesWidth (const Image< T > &img, size_t maxval=50, size_t defaultval=0, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
template<typename T >
size_t crn::StrokesHeight (const Image< T > &img, size_t maxval=50, size_t defaultval=0, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
size_t crn::EstimateLinesXHeight (const ImageGray &img, unsigned int xdiv=16)
 Computes the mean text line x-height. More...
 
size_t crn::EstimateLeading (const ImageGray &img)
 Computes the median distance between two baselines. More...
 
Angle< Radiancrn::EstimateSkew (const ImageGray &img)
 Estimates the mean skew of the document's lines. More...
 
template<typename T >
ImageRGB crn::RandomColors (const Image< T > &img, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
template<typename T , typename CMP = std::less<T>>
ImageBW crn::Threshold (const Image< T > &img, T thresh, CMP cmp=std::less< T >{})
 
template<typename T >
ImageBW crn::Niblack (const Image< T > &img, size_t halfwin, double k=0.5, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
template<typename T >
ImageBW crn::Sauvola (const Image< T > &img, size_t halfwin, double k=0.5, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
template<typename T >
ImageBW crn::kMeansHisto (const Image< T > &img, size_t classes, size_t black_classes, size_t maxcnt=10000, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
template<typename T >
ImageBW crn::LocalMin (const Image< T > &img, size_t area=1, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
template<typename T >
ImageBW crn::LocalMax (const Image< T > &img, size_t area=1, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
template<typename T >
ImageBW crn::Fisher (const Image< T > &img, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
template<typename T >
ImageBW crn::Entropy (const Image< T > &img, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
template<typename T >
ImageBW crn::Otsu (const Image< T > &img, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr)
 
ImageBW crn::MakeImageBW (const ImageGray &img)
 

Detailed Description

Typedef Documentation

using crn::ImageDoubleGray = typedef Image<double>

double Grayscale image class

This class is for grayscale images. Values in pixels' vector represent values for luminosity.

Author
Yann LEYDIER
Date
August 2007
Version
0.4

Definition at line 87 of file CRNImageFormats.h.

using crn::ImageGray = typedef Image<uint8_t>

Grayscale image class.

This class is for grayscale images. Values in pixels' vector represent values for luminosity.

Author
Yann LEYDIER
Date
August 2007
Version
0.4

Definition at line 59 of file CRNImageFormats.h.

using crn::ImageIntGray = typedef Image<int>

Int grayscale image class.

This class is for grayscale images. Values in pixels' vector represent values for luminosity.

Author
Yann LEYDIER
Date
August 2007
Version
0.4

Definition at line 73 of file CRNImageFormats.h.

Function Documentation

template<typename T >
void crn::Abs ( Image< T > &  img,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)
noexcept

Replaces each pixel by its absolute value.

Definition at line 47 of file CRNImageGray.h.

void crn::AutoContrast ( ImageGray img)

Stretches the histogram

Stretches the histogram

Parameters
[in]imgthe image to modify

Definition at line 516 of file CRNImageGray.cpp.

template<typename T >
ImageBW crn::Entropy ( const Image< T > &  img,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Creates a BW image using the entropy threshold

Parameters
[in]imgthe image to binarize
Returns
the newly created image or nullptr if the image was not allocated

Definition at line 553 of file CRNImageGray.h.

size_t crn::EstimateLeading ( const ImageGray img)

Computes the median distance between two baselines.

Warning
very slow
Parameters
[in]imgthe source image
Returns
the median distance between two baselines

Definition at line 673 of file CRNImageGray.cpp.

size_t crn::EstimateLinesXHeight ( const ImageGray img,
unsigned int  xdiv = 16 
)

Computes the mean text line x-height.

Computes the mean text line x-height

Parameters
[in]imgthe source image
Returns
the mean text line x-height

Definition at line 616 of file CRNImageGray.cpp.

Angle< Radian > crn::EstimateSkew ( const ImageGray img)

Estimates the mean skew of the document's lines.

Estimates the mean skew of the document's lines

Parameters
[in]imgthe source image
Returns
the mean angle of the document's lines

Definition at line 727 of file CRNImageGray.cpp.

template<typename T >
ImageBW crn::Fisher ( const Image< T > &  img,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Creates a BW image using the Fisher criterion

Parameters
[in]imgthe image to binarize
Returns
the newly created image or nullptr if the image was not allocated

Definition at line 521 of file CRNImageGray.h.

Histogram crn::HorizontalProjection ( const ImageGray img)

Computes the horizontal projection.

Computes the horizontal projection

Returns
an histogram containing the projection

Definition at line 567 of file CRNImageGray.cpp.

template<typename T >
ImageBW crn::kMeansHisto ( const Image< T > &  img,
size_t  classes,
size_t  black_classes,
size_t  maxcnt = 10000,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Creates a BW image through a classification of the histogram

Parameters
[in]imgthe image to binarize
[in]classesthe total number of classes to compute
[in]black_classesthe total number of classes that represent the black pixels
[in]maxcntthe maximal number of loops
Returns
the newly created image or nullptr if the image was not allocated

Definition at line 335 of file CRNImageGray.h.

template<typename T >
ImageBW crn::LocalMax ( const Image< T > &  img,
size_t  area = 1,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Creates a BW image the local maxima

Parameters
[in]imgthe image to binarize
[in]areathe half window size (window size = 1 + 2 * area).
Returns
the newly created image

Definition at line 463 of file CRNImageGray.h.

template<typename T >
ImageBW crn::LocalMin ( const Image< T > &  img,
size_t  area = 1,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Creates a BW image the local minima

Parameters
[in]imgthe image to binarize
[in]areathe half window size (window size = 1 + 2 * area).
Returns
the newly created image or nullptr if the image was not allocated

Definition at line 404 of file CRNImageGray.h.

template<typename T >
Histogram crn::MakeHistogram ( const Image< T > &  img,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Creates an histogram from the pixels

Parameters
[in]imgthe image to binarize
Returns
the histogram

Definition at line 64 of file CRNImageGray.h.

Histogram crn::MakeHistogram ( const ImageGray img)

Creates an histogram from the pixels.

Creates an histogram from the pixels

Parameters
[in]imgthe image to binarize
Returns
the histogram

Definition at line 601 of file CRNImageGray.cpp.

ImageBW crn::MakeImageBW ( const ImageGray img)

Definition at line 935 of file CRNImageGray.cpp.

template<typename T >
ImageBW crn::Niblack ( const Image< T > &  img,
size_t  halfwin,
double  k = 0.5,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Creates a BW image using Niblack's algorithm the binarisation use a threshold on a square window of neighbouring pixels the threshold t is calculated by

  • mean m
  • standard deviation s
  • parameter k Pixels strictly inferior to the threshold become black, the others white.

t = m + k*s

Parameters
[in]imgthe image to binarize
[in]halfwinsize of the square window of neighbouring pixels, from the border of the window to the central pixel
[in]kparameter k
Returns
the newly created image

Definition at line 229 of file CRNImageGray.h.

template<typename T >
ImageBW crn::Otsu ( const Image< T > &  img,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Creates a BW image using the Otsu's algorithm

Parameters
[in]imgthe image to binarize
Returns
the newly created image or nullptr if the image was not allocated

Definition at line 585 of file CRNImageGray.h.

template<typename T >
ImageRGB crn::RandomColors ( const Image< T > &  img,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Exports to an RGB image with random colors

Parameters
[in]imgthe source image
Returns
the newly created image

Definition at line 177 of file CRNImageGray.h.

template<typename T >
ImageBW crn::Sauvola ( const Image< T > &  img,
size_t  halfwin,
double  k = 0.5,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Creates a BW image using Sauvola's algorithm the binarisation use a threshold on a square window of neighbouring pixels the threshold t is calculated by

  • mean m
  • standard deviation s
  • dynamic range of std.dev. R
  • parameter k Pixels strictly inferior to the threshold become black, the others white.

t = m * (1 + k * (s / R - 1))

Parameters
[in]imgthe image to binarize
[in]halfwinsize of the square window of neighbouring pixels, from the border of the window to the central pixel
[in]kparameter k
Returns
the newly created image

Definition at line 282 of file CRNImageGray.h.

void crn::Sqrt ( ImageDoubleGray img)
noexcept

Replaces the pixels with their square root.

Replaces the pixels with their square root

Parameters
[in]imgthe image to modify

Definition at line 507 of file CRNImageGray.cpp.

template<typename T >
size_t crn::StrokesHeight ( const Image< T > &  img,
size_t  maxval = 50,
size_t  defaultval = 0,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Computes the mean stroke height

Parameters
[in]imgthe image to binarize
[in]maxvalif the mean stroke height is > maxval, then defaultval is returned
[in]defaultvalthe value returned if no mean stroke height can be computed
Returns
the mean stroke height

Definition at line 131 of file CRNImageGray.h.

template<typename T >
size_t crn::StrokesWidth ( const Image< T > &  img,
size_t  maxval = 50,
size_t  defaultval = 0,
typename std::enable_if< std::is_arithmetic< T >::value >::type *  dummy = nullptr 
)

Computes the mean stroke width

Parameters
[in]imgthe image to binarize
[in]maxvalif the mean stroke width is > maxval, then defaultval is returned
[in]defaultvalthe value returned if no mean stroke width can be computed
Returns
the mean stroke width

Definition at line 90 of file CRNImageGray.h.

template<typename T , typename CMP = std::less<T>>
ImageBW crn::Threshold ( const Image< T > &  img,
thresh,
CMP  cmp = std::less<T>{} 
)

Creates a BW image using a fixed threshold. Pixels strictly inferior to the threshold become black, the others white.

Parameters
[in]imgthe image to binarize
[in]threshthe threshold
Returns
the newly created image

Definition at line 204 of file CRNImageGray.h.

Histogram crn::VerticalProjection ( const ImageGray img)

Computes the vertical projection.

Computes the vertical projection

Returns
an histogram containing the projection

Definition at line 583 of file CRNImageGray.cpp.