#include <qgarlib/NiblackBinaryImage.H>
Inheritance diagram for qgar::NiblackBinaryImage:

The thresholding is based on the method proposed by W. Niblack in [Niblack, 1986]. As suggested by Trier and Jain in [Trier and Jain, 1995], this basic method is completed with the postprocessing step first proposed by S.D. Yanowitz and A.M. Bruckstein in [Yanowitz and Bruckstein, 1989].
Two extra global thresholds are used, so that adaptive binarization is replaced by global thresholding for all pixels which are very bright or very dark.
Definition at line 81 of file NiblackBinaryImage.H.
Public Types | |
Types | |
| typedef BinaryImage::value_type | value_type |
| Type of the elements stored in the pixel map. | |
| typedef value_type & | reference |
| Reference to qgar::NiblackBinaryImage::value_type. | |
| typedef const value_type & | const_reference |
| Constant reference to qgar::NiblackBinaryImage::value_type. | |
| typedef value_type * | pointer |
| Pointer to qgar::NiblackBinaryImage::value_type. | |
| typedef const value_type * | const_pointer |
| Constant pointer to qgar::NiblackBinaryImage::value_type. | |
Public Member Functions | |
CONSTRUCTORS | |
| NiblackBinaryImage (const GreyLevelImage &anImg, const int aLowThres=20, const int aHighThres=150, const int aMaskSize=15, const float aK=-0.2, const float aPostThres=0.0) | |
| Construct from a grey-level image. | |
Access to image characteristics | |
| int | width () const |
| Get the image width. | |
| int | height () const |
| Get the image height. | |
| int | bytesPerPixel () const |
| Get the number of bytes per pixel. | |
Access to pixel values | |
| value_type | pixel (unsigned int aX, unsigned int aY) const |
| Get a pixel value. | |
| void | row (unsigned int aRowIdx, pointer aRow) const |
| Get a row of pixels. | |
| void | column (unsigned int aColIdx, pointer aCol) const |
| Get a column of pixels. | |
Access to direct transformations of the pixel map | |
| pointer | pPixel (unsigned int aRowIdx, unsigned int aColIdx) const |
| Get a pointer on a given pixel of the image. | |
| pointer | pRow (unsigned int aRowIdx) const |
| Get a pointer on a row of pixels. | |
| pointer | pColumn (unsigned int aColIdx) const |
| Get a pointer on a column of pixels. | |
| pointer | pPixMap () const |
| Get the pointer to the pixel map. | |
Set pixel values | |
| void | setPixel (unsigned int aX, unsigned int aY, value_type aPixVal) |
| Set a pixel value. | |
| void | setRow (unsigned int aRowIdx, const_pointer const aRow) |
| Set a given row of pixels. | |
| void | setColumn (unsigned int aColIdx, const_pointer const aCol) |
| Set a given column of pixels. | |
Draw in the pixel map | |
| void | draw (const Segment &aSeg, value_type aPixVal=(value_type) 1) |
| Draw a segment in the pixel map. | |
Copy | |
| GenImage | shallowCopy () |
| Shallow copy: The pixel map of the current image is not duplicated. | |
Operators | |
| |
| template<template< class > class OtherCheckPolicy> | |
| GenImage< value_type, GenImage_NoCheck > | operator+ (const GenImage< value_type, OtherCheckPolicy > &anImg) const |
| Same as function qgar::GenImage::plus. | |
| template<template< class > class OtherCheckPolicy> | |
| GenImage & | operator+= (const GenImage< value_type, OtherCheckPolicy > &anImg) |
| Same as function qgar::GenImage::plusEqual. | |
| template<template< class > class OtherCheckPolicy> | |
| GenImage< value_type, GenImage_NoCheck > | operator- (const GenImage< value_type, OtherCheckPolicy > &anImg) const |
| Same as function qgar::GenImage::minus. | |
| template<template< class > class OtherCheckPolicy> | |
| GenImage & | operator-= (const GenImage< value_type, OtherCheckPolicy > &anImg) |
| Same as function qgar::GenImage::minusEqual. | |
| template<template< class > class OtherCheckPolicy> | |
| GenImage< value_type, GenImage_NoCheck > | operator * (const GenImage< value_type, OtherCheckPolicy > &anImg) const |
| Same as function qgar::GenImage::times. | |
| template<template< class > class OtherCheckPolicy> | |
| GenImage & | operator *= (const GenImage< value_type, OtherCheckPolicy > &anImg) |
| Same as function qgar::GenImage::timesEqual. | |
Functional operators | |
| |
| template<template< class > class OtherCheckPolicy> | |
| GenImage< value_type, GenImage_NoCheck > | plus (const GenImage< value_type, OtherCheckPolicy > &anImg) const |
| Add each pixel of the given image to the corresponding pixel of the current image and store each result in a new pixel map. | |
| template<template< class > class OtherCheckPolicy> | |
| GenImage & | plusEqual (const GenImage< value_type, OtherCheckPolicy > &anImg) throw (QgarErrorDomain) |
| Add a given image to the current image. | |
| template<template< class > class OtherCheckPolicy> | |
| GenImage< value_type, GenImage_NoCheck > | minus (const GenImage< value_type, OtherCheckPolicy > &anImg) const |
| Subtract each pixel of the given image to the corresponding pixel of the current image and store each result in a new pixel map. | |
| template<template< class > class OtherCheckPolicy> | |
| GenImage & | minusEqual (const GenImage< value_type, OtherCheckPolicy > &anImg) throw (QgarErrorDomain) |
| Subtract a given image to the current image. | |
| template<template< class > class OtherCheckPolicy> | |
| GenImage< value_type, GenImage_NoCheck > | times (const GenImage< value_type, OtherCheckPolicy > &anImg) const |
| Multiply each pixel of the given image to the corresponding pixel of the current image and store each result in a new pixel map. | |
| template<template< class > class OtherCheckPolicy> | |
| GenImage & | timesEqual (const GenImage< value_type, OtherCheckPolicy > &anImg) throw (QgarErrorDomain) |
| Multiply a given image by the current image. | |
File storage | |
| void | save (AbstractPbmPlusFile &aPbmPlusFile) const |
| Store current image into a PBM+ file. | |
Border mirroring | |
| int | borderRows (int aRowIdx) const |
| Mirror border rows for convolutions. | |
| int | borderCols (int aColIdx) const |
| Mirror border columns for convolutions. | |
Protected Member Functions | |
Auxiliaries | |
| void | copyBox (const GenImage< value_type, CheckPolicy > &anImg, unsigned int aXTopLeft, unsigned int aYTopLeft, unsigned int aXBottomRight, unsigned int aYBottomRight, value_type aPixVal=static_cast< value_type >(0)) |
| Copy a rectangular area of the given image into the current image. | |
Protected Attributes | |
Representation of an image | |
| unsigned int | _bytesPerPixel |
| Number of bytes per pixel. | |
| int * | _pRefCnt |
| Reference counter. | |
| int | _width |
| Image width. | |
| int | _height |
| Image height. | |
| pointer | _pPixMap |
| Pointer to the pixel map, organized as consecutive rows. | |
Private Member Functions | |
Auxiliaries | |
| void | PRIVATEgetBlackLabels (Component::label_type *aPMapCCImg, Component::label_type *aBuffer) |
| Get a line of labels from a component image and set pixels from WHITE components to 0. | |
|
|
Constant pointer to qgar::NiblackBinaryImage::value_type.
Reimplemented from qgar::GenImage< T, CheckPolicy >. Definition at line 118 of file NiblackBinaryImage.H. |
|
|
Constant reference to qgar::NiblackBinaryImage::value_type.
Reimplemented from qgar::GenImage< T, CheckPolicy >. Definition at line 108 of file NiblackBinaryImage.H. |
|
|
Pointer to qgar::NiblackBinaryImage::value_type.
Reimplemented from qgar::GenImage< T, CheckPolicy >. Definition at line 113 of file NiblackBinaryImage.H. |
|
|
Reference to qgar::NiblackBinaryImage::value_type.
Reimplemented from qgar::GenImage< T, CheckPolicy >. Definition at line 103 of file NiblackBinaryImage.H. |
|
|
Type of the elements stored in the pixel map.
Reimplemented from qgar::GenImage< T, CheckPolicy >. Definition at line 98 of file NiblackBinaryImage.H. |
|
||||||||||||||||||||||||||||
|
Construct from a grey-level image. Niblack's method itself relies on computing the local mean m and the local standard deviation s in a aMaskSize X aMaskSize neighborhood and on setting the dynamic threshold at each point to m + aK * s. The default values are those suggested by Trier and Jain. The postprocessing step proposed by Yanowitz and Bruckstein removes components for which the average gradient of the edge pixels is below the threshold aPostThres (its default value is 0, which corresponds to no postprocessing). No local threshold is used if a pixel is darker than aLowThres or brighter than aHighThres.
Definition at line 60 of file NiblackBinaryImage.C. References qgar::GenImage< T, CheckPolicy >::_height, qgar::GenImage< T, CheckPolicy >::_width, qgar::ConnectedComponents::accessComponentImage(), qgar::ConnectedComponents::componentCnt(), qgar::GenImage< T, CheckPolicy >::pPixMap(), PRIVATEgetBlackLabels(), qgar::qgFill(), qgar::GenImage< T, CheckPolicy >::row(), and qgar::GenImage< T, CheckPolicy >::setRow(). |
|
||||||||||
|
Mirror border columns for convolutions.
Definition at line 1052 of file GenImage.TCC. |
|
||||||||||
|
Mirror border rows for convolutions.
Definition at line 1036 of file GenImage.TCC. |
|
|||||||||
|
Get the number of bytes per pixel.
Definition at line 369 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::_bytesPerPixel. |
|
||||||||||||||||
|
Get a column of pixels.
|
|
||||||||||||||||||||||||||||||||
|
Copy a rectangular area of the given image into the current image. The sides of the rectangle are parallel to the coordinate axis.
Definition at line 1074 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::_pPixMap, qgar::GenImage< T, CheckPolicy >::height(), qgar::GenImage< T, CheckPolicy >::pPixMap(), qgar::qgFill(), and qgar::GenImage< T, CheckPolicy >::width(). Referenced by qgar::GenImage< T, CheckPolicy >::GenImage(). |
|
||||||||||||||||
|
Draw a segment in the pixel map. The segment pixels are set using Bresenham's algorithm. See W.M. Newman and R.F. Sproull, Principles of Interactive Computer Graphics, pp. 25-26.
Definition at line 535 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::setPixel(), qgar::AbstractGenPrimitive< T >::source(), qgar::AbstractGenPrimitive< T >::target(), qgar::GenPoint< T >::x(), and qgar::GenPoint< T >::y(). |
|
|||||||||
|
||||||||||||||
|
Subtract each pixel of the given image to the corresponding pixel of the current image and store each result in a new pixel map.
Definition at line 867 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::GenImage(). Referenced by qgar::GenImage< T, CheckPolicy >::operator-(). |
|
||||||||||||||
|
Subtract a given image to the current image.
Definition at line 877 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::height(), qgar::GenImage< T, CheckPolicy >::pPixMap(), and qgar::GenImage< T, CheckPolicy >::width(). Referenced by qgar::GenImage< T, CheckPolicy >::operator-=(). |
|
||||||||||||||
|
Same as function qgar::GenImage::times.
Definition at line 926 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::times(). |
|
||||||||||||||
|
Same as function qgar::GenImage::timesEqual.
Definition at line 937 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::timesEqual(). |
|
||||||||||||||
|
Same as function qgar::GenImage::plus.
Definition at line 767 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::plus(). |
|
||||||||||||||
|
Same as function qgar::GenImage::plusEqual.
Definition at line 778 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::plusEqual(). |
|
||||||||||||||
|
Same as function qgar::GenImage::minus.
Definition at line 846 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::minus(). |
|
||||||||||||||
|
Same as function qgar::GenImage::minusEqual.
Definition at line 857 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::minusEqual(). |
|
||||||||||
|
Get a pointer on a column of pixels.
Definition at line 453 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::_pPixMap. |
|
||||||||||||||||
|
Get a pixel value.
Definition at line 384 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::_pPixMap, and qgar::GenImage< T, CheckPolicy >::_width. Referenced by qgar::AbstractGradientImage::dxPixel(), qgar::AbstractGradientImage::dyPixel(), qgar::PruneSmallCCBinaryImage::isNeighbor(), qgar::MapleFile::MapleFile(), and qgar::PruneSmallCCBinaryImage::PruneSmallCCBinaryImage(). |
|
||||||||||||||
|
Add each pixel of the given image to the corresponding pixel of the current image and store each result in a new pixel map.
Definition at line 788 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::GenImage(). Referenced by qgar::GenImage< T, CheckPolicy >::operator+(). |
|
||||||||||||||
|
Add a given image to the current image. Add each pixel of the given image to the corresponding pixel of the current image and store each result in the pixel map of the current image.
Definition at line 797 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::height(), qgar::GenImage< T, CheckPolicy >::pPixMap(), and qgar::GenImage< T, CheckPolicy >::width(). Referenced by qgar::GenImage< T, CheckPolicy >::operator+=(). |
|
||||||||||||||||
|
Get a pointer on a given pixel of the image.
Definition at line 432 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::_pPixMap, and qgar::GenImage< T, CheckPolicy >::_width. |
|
|||||||||
|
||||||||||||
|
Get a line of labels from a component image and set pixels from WHITE components to 0.
Definition at line 251 of file NiblackBinaryImage.C. References qgar::GenImage< T, CheckPolicy >::_width. Referenced by NiblackBinaryImage(). |
|
||||||||||
|
Get a pointer on a row of pixels.
Definition at line 443 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::_pPixMap, and qgar::GenImage< T, CheckPolicy >::_width. |
|
||||||||||||||||
|
Get a row of pixels.
Referenced by qgar::CleanedBinaryImage::CleanedBinaryImage(), qgar::LinDilatedImage::dilateAll(), qgar::LinDilatedBinaryImage::dilateAll(), qgar::LinErodedImage::erodeAll(), qgar::LinErodedBinaryImage::erodeAll(), qgar::IsotropicDilatedBinaryImage::IsotropicDilatedBinaryImage(), NiblackBinaryImage(), and qgar::GenImage< T, CheckPolicy >::save(). |
|
||||||||||
|
Store current image into a PBM+ file. The given PBM+ file is opened (in WRITE ONLY mode) at the call, and closed before returning.
Definition at line 1005 of file GenImage.TCC. References qgar::AbstractFile::close(), qgar::AbstractFile::openWONLY(), qgar::AbstractPbmPlusFile::pRow(), qgar::GenImage< T, CheckPolicy >::row(), qgar::AbstractPbmPlusFile::setColCnt(), qgar::AbstractPbmPlusFile::setRowCnt(), and qgar::AbstractPbmPlusFile::writeRow(). |
|
||||||||||||||||
|
Set a given column of pixels.
|
|
||||||||||||||||||||
|
Set a pixel value.
Definition at line 478 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::_pPixMap, and qgar::GenImage< T, CheckPolicy >::_width. Referenced by qgar::GenImage< T, CheckPolicy >::draw(), and qgar::PruneSmallCCBinaryImage::removeComponent(). |
|
||||||||||||||||
|
Set a given row of pixels.
Referenced by qgar::CleanedBinaryImage::CleanedBinaryImage(), qgar::LinDilatedImage::dilateAll(), qgar::LinDilatedBinaryImage::dilateAll(), qgar::LinErodedImage::erodeAll(), qgar::LinErodedBinaryImage::erodeAll(), qgar::GenImage< T, CheckPolicy >::GenImage(), qgar::IsotropicDilatedBinaryImage::IsotropicDilatedBinaryImage(), and NiblackBinaryImage(). |
|
|||||||||
|
Shallow copy: The pixel map of the current image is not duplicated.
Definition at line 691 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::_bytesPerPixel, qgar::GenImage< T, CheckPolicy >::_pPixMap, and qgar::GenImage< T, CheckPolicy >::_pRefCnt. Referenced by qgar::AbstractGradientImage::shallowCopy(). |
|
||||||||||||||
|
Multiply each pixel of the given image to the corresponding pixel of the current image and store each result in a new pixel map.
Definition at line 947 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::GenImage(). Referenced by qgar::GenImage< T, CheckPolicy >::operator *(). |
|
||||||||||||||
|
Multiply a given image by the current image. Multiply each pixel of the given image by the corresponding pixel of the current image and store each result in the pixel map of the current image.
Definition at line 958 of file GenImage.TCC. References qgar::GenImage< T, CheckPolicy >::height(), qgar::GenImage< T, CheckPolicy >::pPixMap(), and qgar::GenImage< T, CheckPolicy >::width(). Referenced by qgar::GenImage< T, CheckPolicy >::operator *=(). |
|
|||||||||
|
|||||
|
Number of bytes per pixel.
Definition at line 1096 of file GenImage.H. Referenced by qgar::GenImage< T, CheckPolicy >::bytesPerPixel(), and qgar::GenImage< T, CheckPolicy >::shallowCopy(). |
|
|||||
|
Image height.
Definition at line 1114 of file GenImage.H. Referenced by qgar::CleanedBinaryImage::CleanedBinaryImage(), qgar::GenImage< T, CheckPolicy >::GenImage(), qgar::GradientLocalMaxImage::GradientLocalMaxImage(), qgar::GradientModuleImage::GradientModuleImage(), qgar::IsotropicDilatedBinaryImage::IsotropicDilatedBinaryImage(), and NiblackBinaryImage(). |
|
|||||
|
|||||
|
Reference counter. Its value represent the number of other images with which the current image shares its pixel map. Definition at line 1104 of file GenImage.H. Referenced by qgar::GenImage< T, CheckPolicy >::shallowCopy(), and qgar::GenImage< T, CheckPolicy >::~GenImage(). |
|
|||||