|
libcrn
3.9.5
A document image processing library
|
Abstract class for images. More...
#include <CRNImage.h>
Inheritance diagram for crn::Image< T >:
Collaboration diagram for crn::Image< T >:Public Types | |
| using | pixel_type = T |
Public Member Functions | |
| Image (size_t w, size_t h, pixel_type val=pixel_type(0)) | |
| Constructor. More... | |
| Image () | |
| Default constructor. More... | |
| Image (size_t w, size_t h, const pixel_type *data) | |
| Constructor from data. More... | |
| Image (const Image &img)=default | |
| Copy constructor. More... | |
| template<typename Y > | |
| Image (const Image< Y > &img) | |
| Copy constructor. More... | |
| Image (const Image< typename BoolNotBool< T >::type > &img) | |
| Copy constructor. More... | |
| template<typename Y > | |
| Image (const Image< Y > &img, const Rect &bbox) | |
| Crop constructor. More... | |
| Image (const Image< typename BoolNotBool< T >::type > &img, const Rect &bbox) | |
| Crop constructor. More... | |
| Image (Image &&img)=default | |
| Move constructor. More... | |
| virtual | ~Image () override=default |
| Destructor. More... | |
| Image & | operator= (const Image &img)=default |
| Copy operator. More... | |
| template<typename Y > | |
| Image & | operator= (const Image< Y > &img) |
| Copy operator. More... | |
| Image & | operator= (const Image< typename BoolNotBool< T >::type > &img) |
| Copy operator. More... | |
| template<typename Y > | |
| void | Assign (const Image< Y > &img) |
| Force copy operator (pixel cast) More... | |
| Image & | operator= (Image &&img)=default |
| Move operator. More... | |
| virtual std::unique_ptr < ImageBase > | Clone () const override |
| void | Swap (Image &other) |
| Swaps two images. More... | |
| virtual void | SavePNG (const Path &fname) const override |
| Saves as PNG file. More... | |
| virtual void | SaveJPEG (const Path &fname, unsigned int qual) const override |
| Saves as JPEG file. More... | |
| template<typename MAT > | |
| MAT | ToMatrix () const |
| Converts to matrix. More... | |
| std::vector< pixel_type >::iterator | begin () |
| std::vector< pixel_type > ::const_iterator | begin () const |
| std::vector< pixel_type >::iterator | end () |
| std::vector< pixel_type > ::const_iterator | end () const |
| std::vector< pixel_type > ::const_iterator | cbegin () const |
| std::vector< pixel_type > ::const_iterator | cend () const |
| std::vector< pixel_type >::pointer | GetPixels () noexcept |
| Gets a pointer to the pixels. More... | |
| std::vector< pixel_type > ::const_pointer | GetPixels () const noexcept |
| Gets a const pointer to the pixels. More... | |
| std::vector< pixel_type > ::reference | At (size_t x, size_t y) noexcept |
| Returns a reference to a pixel. More... | |
| std::vector< pixel_type > ::reference | At (size_t offset) noexcept |
| Returns a reference to a pixel. More... | |
| std::vector< pixel_type > ::const_reference | At (size_t x, size_t y) const noexcept |
| Returns a reference to a pixel. More... | |
| std::vector< pixel_type > ::const_reference | At (size_t offset) const noexcept |
| Returns a reference to a pixel. More... | |
| bool | operator== (const Image &other) const |
| Tests equality. More... | |
| bool | operator!= (const Image &other) const |
| Tests equality. More... | |
| Image & | operator+= (const Image &img) |
| Adds another image. More... | |
| Image & | operator-= (const Image &img) |
| Subtracts another image. More... | |
| Image & | operator*= (double f) |
| Multiplies all pixels. More... | |
| Image & | operator*= (const Image &img) |
| Multiplies with another image's pixels. More... | |
| Image & | operator/= (const Image &img) |
| Divides by another image's pixels. More... | |
| void | Negative () |
| Negative. More... | |
| void | Complement (pixel_type maxval=std::numeric_limits< pixel_type >::max()) |
| Complement. More... | |
| template<typename Y > | |
| void | Blit (const Image< Y > &src, const Rect &srczone, size_t dx, size_t dy) |
| Copies a part of an image. More... | |
| void | FloodFill (size_t x, size_t y, const pixel_type &val, crn::DistanceType dist=crn::DistanceType::D4) |
| Flood fills a portion of the image. More... | |
| void | ScanFill (size_t x, size_t y, const pixel_type &val, crn::DistanceType dist=crn::DistanceType::D4) |
| Fills a portion of the image. More... | |
| void | DrawRect (const Rect &r, pixel_type color, bool filled=false) |
| Draws a rectangle using a specified color. More... | |
| void | DrawLine (size_t x1, size_t y1, size_t x2, size_t y2, pixel_type color) |
| Draws a line using a specified color. More... | |
| virtual void | ScaleToSize (size_t w, size_t h) override |
| Scales the image. More... | |
| void | Flip (const Orientation &ori) |
| Flips the image. More... | |
| template<typename CMP = std::less<pixel_type>> | |
| void | Dilate (const MatrixInt &strel, CMP cmp=std::less< pixel_type >{}) |
| Morphological dilatation. More... | |
| template<typename CMP = std::less<pixel_type>> | |
| void | Erode (const MatrixInt &strel, CMP cmp=std::less< pixel_type >{}) |
| Morphological erosion. More... | |
| template<typename CMP = std::less<pixel_type>> | |
| void | FastDilate (size_t halfwin, size_t index=0, CMP cmp=std::less< pixel_type >{}) |
| Morphological dilatation. More... | |
| template<typename CMP = std::less<pixel_type>> | |
| void | FastErode (size_t halfwin, size_t index=0, CMP cmp=std::less< pixel_type >{}) |
| Morphological erosion. More... | |
| void | Convolve (const MatrixDouble &mat) |
| Convolution. More... | |
| void | GaussianBlur (double sigma) |
| Gaussian blur. More... | |
| template<typename Y > | |
| Image< T > & | operator= (const Image< Y > &img) |
Public Member Functions inherited from crn::ImageBase | |
| virtual | ~ImageBase () |
| ImageBase (size_t w, size_t h) | |
| ImageBase (const ImageBase &)=default | |
| ImageBase (ImageBase &&)=default | |
| ImageBase & | operator= (const ImageBase &)=default |
| ImageBase & | operator= (ImageBase &&)=default |
| size_t | GetWidth () const noexcept |
| size_t | GetHeight () const noexcept |
| Rect | GetBBox () const noexcept |
| size_t | Size () const noexcept |
Protected Attributes | |
| std::vector< pixel_type > | pixels |
Protected Attributes inherited from crn::ImageBase | |
| size_t | width |
| size_t | height |
Abstract class for images.
This class is the highest ancestor for all image classes.
Definition at line 141 of file CRNImage.h.
| using crn::Image< T >::pixel_type = T |
Definition at line 144 of file CRNImage.h.
| crn::Image< T >::Image | ( | size_t | w, |
| size_t | h, | ||
| pixel_type | val = pixel_type(0) |
||
| ) |
Constructor.
Constructor for this class
| ExceptionRuntime | cannot allocate pixels |
| [in] | w | width value to be set for this image |
| [in] | h | height value to be set for this image |
| [in] | val | default value for pixels |
Definition at line 55 of file CRNImage.hpp.
|
inline |
Default constructor.
Definition at line 153 of file CRNImage.h.
| crn::Image< T >::Image | ( | size_t | w, |
| size_t | h, | ||
| const pixel_type * | data | ||
| ) |
Constructor from data.
Constructor for this class
| ExceptionRuntime | cannot allocate pixels |
| [in] | w | width value to be set for this image |
| [in] | h | height value to be set for this image |
| [in] | data | the data to copy to the new image |
Definition at line 71 of file CRNImage.hpp.
|
default |
Copy constructor.
|
explicit |
Copy constructor.
Copy constructor
| [in] | img | the image to copy |
Definition at line 79 of file CRNImage.hpp.
|
explicit |
Copy constructor.
Copy constructor
| [in] | img | the image to copy |
Definition at line 87 of file CRNImage.hpp.
| crn::Image< T >::Image | ( | const Image< Y > & | img, |
| const Rect & | bbox | ||
| ) |
Crop constructor.
Crop constructor
| [in] | img | the image to copy |
| [in] | bbox | the zone to copy |
Definition at line 99 of file CRNImage.hpp.
| crn::Image< T >::Image | ( | const Image< typename BoolNotBool< T >::type > & | img, |
| const Rect & | bbox | ||
| ) |
Crop constructor.
Crop constructor
| [in] | img | the image to copy |
| [in] | bbox | the zone to copy |
Definition at line 111 of file CRNImage.hpp.
|
default |
Move constructor.
|
overridevirtualdefault |
Destructor.
Force copy operator (pixel cast)
Force copy operator: pixel values are cast
| [in] | img | the image to copy |
Definition at line 147 of file CRNImage.hpp.
|
inlinenoexcept |
Returns a reference to a pixel.
Definition at line 224 of file CRNImage.h.
|
inlinenoexcept |
Returns a reference to a pixel.
Definition at line 226 of file CRNImage.h.
|
inlinenoexcept |
Returns a reference to a pixel.
Definition at line 228 of file CRNImage.h.
|
inlinenoexcept |
Returns a reference to a pixel.
Definition at line 230 of file CRNImage.h.
|
inline |
Definition at line 211 of file CRNImage.h.
|
inline |
Definition at line 212 of file CRNImage.h.
| void crn::Image< T >::Blit | ( | const Image< Y > & | src, |
| const Rect & | srczone, | ||
| size_t | dx, | ||
| size_t | dy | ||
| ) |
Copies a part of an image.
Copies a part of an image
| [in] | src | the image to copy |
| [in] | srczone | the zone to copy |
| [in] | dx | the abscissa where to copy |
| [in] | dy | the ordinate where to copy |
Definition at line 282 of file CRNImage.hpp.
|
inline |
Definition at line 215 of file CRNImage.h.
|
inline |
Definition at line 216 of file CRNImage.h.
|
inlineoverridevirtual |
Implements crn::ImageBase.
Definition at line 184 of file CRNImage.h.
| void crn::Image< T >::Complement | ( | pixel_type | maxval = std::numeric_limits<pixel_type>::max() | ) |
Complement.
Complement
| [in] | maxval | maximum value |
Definition at line 270 of file CRNImage.hpp.
| void crn::Image< T >::Convolve | ( | const MatrixDouble & | mat | ) |
Convolution.
Convolves the image with a matrix.
| ExceptionDimension | even matrix |
| ExceptionDomain | matrix bigger than image |
| [in] | mat | The convolution matrix |
Definition at line 1023 of file CRNImage.hpp.
| void crn::Image< T >::Dilate | ( | const MatrixInt & | strel, |
| CMP | cmp = std::less<pixel_type>{} |
||
| ) |
Morphological dilatation.
Morphological dilatation
| ExceptionDimension | even element |
| [in] | strel | The structuring element |
Definition at line 761 of file CRNImage.hpp.
| void crn::Image< T >::DrawLine | ( | size_t | x1, |
| size_t | y1, | ||
| size_t | x2, | ||
| size_t | y2, | ||
| pixel_type | color | ||
| ) |
Draws a line using a specified color.
Draws a line using a specified color
| [in] | x1 | the beginning abscissa |
| [in] | y1 | the beginning ordinate |
| [in] | x2 | the ending abscissa |
| [in] | y2 | the ending ordinate |
| [in] | color | a pixel in any compatible format |
Definition at line 543 of file CRNImage.hpp.
| void crn::Image< T >::DrawRect | ( | const Rect & | r, |
| pixel_type | color, | ||
| bool | filled = false |
||
| ) |
Draws a rectangle using a specified color.
Draws a rectangle using a specified color
| [in] | r | the rectangle to draw |
| [in] | color | a pixel in any compatible format |
| [in] | filled | is the rectangle filled? (default = no) |
Definition at line 515 of file CRNImage.hpp.
|
inline |
Definition at line 213 of file CRNImage.h.
|
inline |
Definition at line 214 of file CRNImage.h.
| void crn::Image< T >::Erode | ( | const MatrixInt & | strel, |
| CMP | cmp = std::less<pixel_type>{} |
||
| ) |
Morphological erosion.
Morphological erosion.
| ExceptionDimension | even element |
| [in] | strel | The structuring element |
Definition at line 827 of file CRNImage.hpp.
| void crn::Image< T >::FastDilate | ( | size_t | halfwin, |
| size_t | index = 0, |
||
| CMP | cmp = std::less<pixel_type>{} |
||
| ) |
Morphological dilatation.
Morphological dilatation (faster than normal dilatation for halfwin >= 8)
| [in] | halfwin | the half window size (window width and height = 2*halfwin+1) |
| [in] | index | the rank of the value to use on each column (0 = regular dilatation, halfwin = something closer to a median filter) |
Definition at line 890 of file CRNImage.hpp.
| void crn::Image< T >::FastErode | ( | size_t | halfwin, |
| size_t | index = 0, |
||
| CMP | cmp = std::less<pixel_type>{} |
||
| ) |
Morphological erosion.
Morphological erosion (faster than normal erosion for halfwin >= 8)
| [in] | halfwin | the half window size (window width and height = 2*halfwin+1) |
| [in] | index | the rank of the value to use on each column (0 = regular erosion, halfwin = something closer to a median filter) |
Definition at line 956 of file CRNImage.hpp.
| void crn::Image< T >::Flip | ( | const Orientation & | ori | ) |
Flips the image.
Flips the image
| ExceptionInvalidArgument | invalid orientation |
| [in] | ori | the orientation of the flip |
Definition at line 729 of file CRNImage.hpp.
| void crn::Image< T >::FloodFill | ( | size_t | x, |
| size_t | y, | ||
| const pixel_type & | val, | ||
| crn::DistanceType | dist = crn::DistanceType::D4 |
||
| ) |
Flood fills a portion of the image.
Flood fills a portion of the image.
| ExceptionDomain | coordinates out of bounds |
| [in] | x | the beginning abscissa |
| [in] | y | the beginning ordinate |
| [in] | val | the value used to fill |
| [in] | dist | the distance to use (DistanceType::D4 or DistanceType::D8) |
Definition at line 311 of file CRNImage.hpp.
| void crn::Image< T >::GaussianBlur | ( | double | sigma | ) |
Gaussian blur.
Gaussian blur
| ExceptionDomain | null or negative sigma |
| ExceptionDimension | matrix bigger than image |
| [in] | sigma | the standard deviation of the Gaussian |
Definition at line 1132 of file CRNImage.hpp.
|
inlinenoexcept |
Gets a pointer to the pixels.
Definition at line 219 of file CRNImage.h.
|
inlinenoexcept |
Gets a const pointer to the pixels.
Definition at line 221 of file CRNImage.h.
| void crn::Image< T >::Negative | ( | ) |
|
inline |
Tests equality.
Definition at line 235 of file CRNImage.h.
| Image< T > & crn::Image< T >::operator*= | ( | double | f | ) |
Multiplies all pixels.
Multiplies all pixels
| [in] | f | the factor |
Definition at line 221 of file CRNImage.hpp.
| Image< T > & crn::Image< T >::operator*= | ( | const Image< T > & | img | ) |
Multiplies with another image's pixels.
Multiplies with another image's pixels
| ExceptionDimension | images have different sizes |
| [in] | img | the image to multiply |
Definition at line 233 of file CRNImage.hpp.
| Image< T > & crn::Image< T >::operator+= | ( | const Image< T > & | img | ) |
Adds another image.
Adds another image
| ExceptionDimension | images have different sizes |
| [in] | img | the image to add |
Definition at line 194 of file CRNImage.hpp.
| Image< T > & crn::Image< T >::operator-= | ( | const Image< T > & | img | ) |
Subtracts another image.
Subtracts another image
| ExceptionDimension | images have different sizes |
| [in] | img | the image to subtract |
Definition at line 208 of file CRNImage.hpp.
| Image< T > & crn::Image< T >::operator/= | ( | const Image< T > & | img | ) |
Divides by another image's pixels.
Divides by another image's pixels
| ExceptionDimension | images have different sizes |
| [in] | img | the image to divide with |
Definition at line 247 of file CRNImage.hpp.
| Image<T>& crn::Image< T >::operator= | ( | const Image< Y > & | img | ) |
Copy operator: pixel values are not cast
| [in] | img | the image to copy |
Definition at line 123 of file CRNImage.hpp.
|
default |
Copy operator.
Copy operator.
| Image< T > & crn::Image< T >::operator= | ( | const Image< typename BoolNotBool< T >::type > & | img | ) |
Copy operator.
Copy operator: pixel values are not cast
| [in] | img | the image to copy |
Definition at line 135 of file CRNImage.hpp.
|
default |
Move operator.
| bool crn::Image< T >::operator== | ( | const Image< T > & | other | ) | const |
Tests equality.
Tests equality
| [in] | other | the image to compare |
Definition at line 178 of file CRNImage.hpp.
|
overridevirtual |
Saves as JPEG file.
Saves as JPEG file
| ExceptionInvalidArgument | unsupported pixel format |
| [in] | fname | full path to the image to save |
| [in] | qual | compression quality [0..100] |
Implements crn::ImageBase.
Definition at line 169 of file CRNImage.hpp.
|
overridevirtual |
Saves as PNG file.
Saves as PNG file
| ExceptionInvalidArgument | unsupported pixel format |
| [in] | fname | full path to the image to save |
Implements crn::ImageBase.
Definition at line 160 of file CRNImage.hpp.
|
overridevirtual |
Scales the image.
Scales the image
| [in] | w | the new width |
| [in] | h | the new height |
Implements crn::ImageBase.
Definition at line 614 of file CRNImage.hpp.
| void crn::Image< T >::ScanFill | ( | size_t | x, |
| size_t | y, | ||
| const pixel_type & | val, | ||
| crn::DistanceType | dist = crn::DistanceType::D4 |
||
| ) |
Fills a portion of the image.
Fills a portion of the image.
| ExceptionDomain | coordinates out of bounds |
| [in] | x | the beginning abscissa |
| [in] | y | the beginning ordinate |
| [in] | val | the value used to fill |
| [in] | dist | the distance to use (DistanceType::D4 or DistanceType::D8) |
Definition at line 363 of file CRNImage.hpp.
|
inline |
Swaps two images.
Definition at line 187 of file CRNImage.h.
Converts to matrix.
Definition at line 200 of file CRNImage.h.
|
protected |
the pixels
Definition at line 295 of file CRNImage.h.
1.8.6