libcrn
3.9.5
A document image processing library
|
A block. More...
#include <CRNBlock.h>
Classes | |
class | masked_pixel_iterator |
Iterator on the pixels the block with BW buffer as mask. More... | |
Public Types | |
using | pixel_iterator = Rect::iterator |
Iterator on the pixels the block. More... | |
Public Member Functions | |
virtual | ~Block () override |
Destructor. More... | |
Block (const Block &)=delete | |
Block & | operator= (const Block &)=delete |
Block (Block &&)=delete | |
Block & | operator= (Block &&)=delete |
void | SetFilename (const Path &nam) |
Sets the default filename of the block. More... | |
const Rect & | GetAbsoluteBBox () const noexcept |
Gets the absolute bounding box of the block. More... | |
Rect | GetRelativeBBox () const |
Gets the relative bounding box of the block. More... | |
void | SetAbsoluteBBox (const Rect &newbox) |
Sets the absolute bounding box of the block. More... | |
void | SetRelativeBBox (Rect newbox) |
Sets the absolute bounding box of the block. More... | |
WBlock | GetParent () |
Gets a reference to the parent of the block. More... | |
WCBlock | GetParent () const |
Gets a reference to the parent of the block. More... | |
WBlock | GetTop () |
Gets a reference to the topmost parent of the block. More... | |
const String & | GetParentTree () const noexcept |
Gets the name of the parent tree of the block. More... | |
bool | IsParent (const Block &b) const |
Checks if a block is a parent of current. More... | |
SBlock | AddChildAbsolute (const String &tree, Rect clip) |
Adds a child to current block. More... | |
SBlock | AddChildAbsolute (const String &tree, Rect clip, const String &name) |
Adds a child to current block with a name. More... | |
SBlock | AddChildAbsoluteAt (const String &tree, Rect clip, size_t pos) |
Adds a child to current block. More... | |
SBlock | AddChildAbsoluteAt (const String &tree, Rect clip, const String &name, size_t pos) |
Adds a child to current block with a name. More... | |
SBlock | AddChildRelative (const String &tree, Rect clip) |
Adds a child to current block. More... | |
SBlock | AddChildRelative (const String &tree, Rect clip, const String &name) |
Adds a child to current block with a name. More... | |
SBlock | AddChildRelativeAt (const String &tree, Rect clip, size_t pos) |
Adds a child to current block. More... | |
SBlock | AddChildRelativeAt (const String &tree, Rect clip, const String &name, size_t pos) |
Adds a child to current block with a name. More... | |
size_t | GetNbChildren (const String &tree) const |
Gets the number of blocks in a child tree. More... | |
SBlock | GetChild (const String &tree, size_t num) |
Gets a block of a child tree. More... | |
SCBlock | GetChild (const String &tree, size_t num) const |
Gets a block of a child tree. More... | |
SBlock | GetChild (const String &tree, const String &name) |
Gets a block of a child tree. More... | |
SCBlock | GetChild (const String &tree, const String &name) const |
Gets a block of a child tree. More... | |
void | RemoveChild (const String &tree, size_t num) |
Removes a block of a child tree. More... | |
void | RemoveChild (const String &tree, const String &name) |
Removes a block of a child tree. More... | |
void | RemoveChild (const String &tree, SBlock b) |
Removes a block of a child tree. More... | |
void | RemoveChildren (const String &tree, const std::set< SBlock > &toremove) |
Removes a set of blocks from a child tree. More... | |
std::vector< String > | GetTreeNames () const |
Gets the list of the tree names. More... | |
bool | HasTree (const String &tname) const |
Checks if a child tree exists. More... | |
void | RemoveTree (const String &tname) |
Deletes a child tree. More... | |
bool | Append (const Path &fname) |
Appends child trees from a file. More... | |
void | Save (const Path &fname) |
Saves the child trees into a file. More... | |
void | Save () |
Saves the child trees into the default file. More... | |
SImageRGB | GetRGB () |
Returns a pointer to the local RGB buffer. More... | |
SImageGray | GetGray (bool create=true) |
Returns a pointer to the local gray buffer. More... | |
SImageBW | GetBW (bool create=true) |
Returns a pointer to the local b&w buffer. More... | |
SImageGradient | GetGradient (bool create=true, double sigma=-1, size_t diffusemaxiter=0, double diffusemaxdiv=std::numeric_limits< double >::max()) |
Returns a pointer to the local gradient buffer. More... | |
void | ReloadImage () |
Reloads the image. More... | |
void | FlushAll (bool recursive=false) |
Frees the local buffers. More... | |
void | FlushRGB (bool recursive=false) |
Frees the local RGB buffer. More... | |
void | FlushGray (bool recursive=false) |
Frees the local gray buffer. More... | |
void | FlushBW (bool recursive=false) |
Frees the local b&w buffer. More... | |
void | FlushGradient (bool recursive=false) |
Frees the local gradient buffer. More... | |
void | SubstituteRGB (const SImageRGB &img) |
Substitutes the RGB buffer with a new one. More... | |
void | SubstituteGray (const SImageGray &img) |
Substitutes the Gray buffer with a new one. More... | |
void | SubstituteBW (const SImageBW &img) |
Substitutes the BW buffer with a new one. More... | |
void | SubstituteGradient (const SImageGradient &img) |
Substitutes the Gradient buffer with a new one. More... | |
UImageIntGray | ExtractCC (const String &tree) |
Creates a child tree with connected components. More... | |
void | FilterMinAnd (const String &tree, size_t minw, size_t minh) |
Filters a child tree. More... | |
void | FilterMinOr (const String &tree, size_t minw, size_t minh) |
Filters a child tree. More... | |
void | FilterMaxAnd (const String &tree, size_t maxw, size_t maxh) |
Filters a child tree. More... | |
void | FilterMaxOr (const String &tree, size_t maxw, size_t maxh) |
Filters a child tree. More... | |
void | FilterBorders (const String &tree, size_t margin) |
Filters a child tree. More... | |
void | FilterWidthRatio (const String &tree, double ratio) |
Filters a child tree. More... | |
void | FilterHeightRatio (const String &tree, double ratio) |
Filters a child tree. More... | |
bool | MergeChildren (const String &tree, double overlap, ImageIntGray *imap=nullptr) |
Merges overlapping children in a tree. More... | |
void | MergeSiblings (const String &tree, size_t index1, size_t index2, ImageIntGray *imap=nullptr) |
Merges two subblocks. More... | |
void | MergeSiblings (const String &tree, Block &sb1, Block &sb2, ImageIntGray *imap=nullptr) |
Merges two subblocks. More... | |
void | GetTreeMeans (const String &tree, double *mwidth, double *mheight, double *marea) const |
Returns the mean width, height and area of the subblocks. More... | |
block_iterator | BlockBegin (const String &tree) |
Returns an iterator on the first block of a tree. More... | |
block_iterator | BlockEnd (const String &tree) |
Returns an iterator after the last block of a tree. More... | |
const_block_iterator | BlockBegin (const String &tree) const |
Returns a const iterator on the first block of a tree. More... | |
const_block_iterator | BlockEnd (const String &tree) const |
Returns a const iterator after the last block of a tree. More... | |
SVector | GetTree (const String &name) |
Returns a list of children. Can be used with CRN_FOREACH. More... | |
SCVector | GetTree (const String &name) const |
Returns a list of children. Can be used with CRN_FOREACH. More... | |
void | SortTree (const String &name, Direction direction) |
Sorts a child tree. More... | |
pixel_iterator | PixelBegin (const String &tree, size_t num) const |
Returns an iterator on the first pixel of the block. More... | |
pixel_iterator | PixelBegin (const SBlock &b) const |
Returns an iterator on the first pixel of the block. More... | |
pixel_iterator | PixelEnd (const String &tree, size_t num) const |
Returns an iterator after the last pixel of the block. More... | |
pixel_iterator | PixelEnd (const SBlock &b) const |
Returns an iterator after the last pixel of the block. More... | |
masked_pixel_iterator | MaskedPixelBegin (const String &tree, size_t num, pixel::BW mask_value=pixel::BWBlack) |
Returns a masked iterator on the first pixel of the block. More... | |
masked_pixel_iterator | MaskedPixelEnd (const String &tree, size_t num, pixel::BW mask_value=pixel::BWBlack) |
Returns a masked iterator on the first pixel of the block. More... | |
masked_pixel_iterator | MaskedPixelBegin (const SBlock &b, pixel::BW mask_value=pixel::BWBlack) |
Returns a masked iterator after the last pixel of the block. More... | |
masked_pixel_iterator | MaskedPixelEnd (const SBlock &b, pixel::BW mask_value=pixel::BWBlack) |
Returns a masked iterator after the last pixel of the block. More... | |
![]() | |
Savable (const String &s=U"") | |
Default constructor. More... | |
virtual | ~Savable () |
Destructor. More... | |
Savable (const Savable &)=delete | |
No copy construction allowed. More... | |
Savable & | operator= (const Savable &)=delete |
No assignment allowed. More... | |
Savable (Savable &&) noexcept | |
Savable & | operator= (Savable &&c) |
const String & | GetName () const |
Returns the name of the object. More... | |
void | SetName (const String &s) |
Sets the name of the object. More... | |
void | SetName (String &&s) noexcept |
Sets the name of the object. More... | |
void | SetUserData (const String &key, SObject value) |
Adds or replaces a user data. More... | |
bool | IsUserData (const String &key) const |
Tests if a user data key exists. More... | |
SObject | GetUserData (const String &key) |
Gets a user data by key. More... | |
String | GetUserDataKey (const SObject &value) const |
Gets a user data key by value. More... | |
const SObject | GetUserData (const String &key) const |
Gets a user data by key. More... | |
void | DeleteUserData (const String &key) |
Deletes a user data entry and frees the value. More... | |
void | ClearUserData () |
Deletes all user data entries. More... | |
Savable (const String &s, const Path &fname) | |
Constructor from file name. More... | |
void | Load (const Path &fname) |
Loads the object from an XML file (Safe) More... | |
void | Save (const Path &fname) |
Saves the object to an XML file (Safe) More... | |
void | Save () |
Saves the object to an already set XML file. More... | |
const Path & | GetFilename () const noexcept |
Returns the file name of the object. More... | |
void | deserialize_internal_data (xml::Element &el) |
Initializes some internal data from an XML element. More... | |
void | serialize_internal_data (xml::Element &el) const |
Dumps some internal data to an XML element. More... | |
![]() | |
virtual | ~Object ()=default |
Static Public Member Functions | |
static SBlock | New (const SImage &src, const String &nam=U"") |
Top block creator. More... | |
static SBlock | New (const Path &ifname, const Path &xfname, const String &nam=U"") |
Constructor from filenames. More... | |
Additional Inherited Members | |
![]() | |
void | setFilename (const Path &fname) |
Overwrites the filename. More... | |
void | setFilename (Path &&fname) noexcept |
Overwrites the filename. More... | |
![]() | |
std::unique_ptr< std::mutex > | filelock |
A block.
A block is a container of other blocks. Each block refers to a source image and has a local copy of a part of it. A top block is typically a page or a double page.
Definition at line 52 of file CRNBlock.h.
Iterator on the pixels the block.
Definition at line 228 of file CRNBlock.h.
|
overridevirtual |
Destructor.
Destructor. Saves the changes on subblock trees.
Definition at line 516 of file CRNBlock.cpp.
|
delete |
|
delete |
Adds a child to current block.
Creates and adds a child to the current block
ExceptionInvalidArgument | uninitialized rectangle |
ExceptionDomain | rectangle is out of bounds |
[in] | tree | The name of the tree to add the subblock |
[in] | clip | The bounding box of the new block, given in absolute coordinates. |
Definition at line 548 of file CRNBlock.cpp.
Adds a child to current block with a name.
Creates and adds a child to the current block with a name
ExceptionInvalidArgument | uninitialized rectangle |
ExceptionDomain | rectangle is out of bounds |
[in] | tree | The name of the tree to add the subblock |
[in] | clip | The bounding box of the new block, given in absolute coordinates. |
[in] | name | The name of the new subblock |
Definition at line 575 of file CRNBlock.cpp.
Adds a child to current block.
Creates and adds a child to the current block at the specified position
ExceptionInvalidArgument | uninitialized rectangle |
ExceptionDomain | rectangle is out of bounds |
[in] | tree | The name of the tree to add the subblock |
[in] | clip | The bounding box of the new block, given in absolute coordinates. |
[in] | pos | The position of the newly created child |
Definition at line 602 of file CRNBlock.cpp.
SBlock Block::AddChildAbsoluteAt | ( | const String & | tree, |
Rect | clip, | ||
const String & | name, | ||
size_t | pos | ||
) |
Adds a child to current block with a name.
Creates and adds a child to the current block with a name at the specified position
ExceptionInvalidArgument | uninitialized rectangle |
ExceptionDomain | rectangle is out of bounds |
[in] | tree | The name of the tree to add the subblock |
[in] | clip | The bounding box of the new block, given in absolute coordinates. |
[in] | name | The name of the new subblock |
[in] | pos | The position of the newly created child |
Definition at line 637 of file CRNBlock.cpp.
Adds a child to current block.
Creates and adds a child to the current block
ExceptionInvalidArgument | uninitialized rectangle |
ExceptionDomain | rectangle is out of bounds |
[in] | tree | The name of the tree to add the subblock |
[in] | clip | The bounding box of the new block, given in relative coordinates. |
Definition at line 670 of file CRNBlock.cpp.
Adds a child to current block with a name.
Creates and adds a child to the current block with a name
ExceptionInvalidArgument | uninitialized rectangle |
ExceptionDomain | rectangle is out of bounds |
[in] | tree | The name of the tree to add the subblock |
[in] | clip | The bounding box of the new block, given in relative coordinates. |
[in] | name | The name of the new subblock |
Definition at line 698 of file CRNBlock.cpp.
Adds a child to current block.
Creates and adds a child to the current block at the specified position
ExceptionInvalidArgument | uninitialized rectangle |
ExceptionDomain | rectangle is out of bounds |
[in] | tree | The name of the tree to add the subblock |
[in] | clip | The bounding box of the new block, given in relative coordinates. |
[in] | pos | The position of the newly created child |
Definition at line 726 of file CRNBlock.cpp.
SBlock Block::AddChildRelativeAt | ( | const String & | tree, |
Rect | clip, | ||
const String & | name, | ||
size_t | pos | ||
) |
Adds a child to current block with a name.
Creates and adds a child to the current block with a name at the specified position
ExceptionInvalidArgument | uninitialized rectangle |
ExceptionDomain | rectangle is out of bounds |
[in] | tree | The name of the tree to add the subblock |
[in] | clip | The bounding box of the new block, given in relative coordinates. |
[in] | name | The name of the new subblock |
[in] | pos | The position of the newly created child |
Definition at line 762 of file CRNBlock.cpp.
bool Block::Append | ( | const Path & | fname | ) |
Appends child trees from a file.
Appends child trees from a file.
ExceptionInvalidArgument | empty file name |
ExceptionIO | file exists but cannot be accessed or has invalid structure |
ExceptionRuntime | the XML file does not fit the block's image |
[in] | fname | The file to load. |
Definition at line 1079 of file CRNBlock.cpp.
Block::block_iterator Block::BlockBegin | ( | const String & | tree | ) |
Returns an iterator on the first block of a tree.
Returns an iterator on the first block of a tree
ExceptionInvalidArgument | tree not found |
[in] | tree | the name of the subblock tree |
Definition at line 334 of file CRNBlock.cpp.
Block::const_block_iterator Block::BlockBegin | ( | const String & | tree | ) | const |
Returns a const iterator on the first block of a tree.
Returns a const_iterator on the first block of a tree
ExceptionInvalidArgument | tree not found |
[in] | tree | the name of the subblock tree |
Definition at line 372 of file CRNBlock.cpp.
Block::block_iterator Block::BlockEnd | ( | const String & | tree | ) |
Returns an iterator after the last block of a tree.
Returns an iterator after the last block of a tree
ExceptionInvalidArgument | tree not found |
[in] | tree | the name of the subblock tree |
Definition at line 354 of file CRNBlock.cpp.
Block::const_block_iterator Block::BlockEnd | ( | const String & | tree | ) | const |
Returns a const iterator after the last block of a tree.
Returns a const_iterator after the last block of a tree
ExceptionInvalidArgument | tree not found |
[in] | tree | the name of the subblock tree |
Definition at line 393 of file CRNBlock.cpp.
UImageIntGray Block::ExtractCC | ( | const String & | tree | ) |
Creates a child tree with connected components.
Creates a child tree with connected components.
Each child block's name is the index of the connected component it represents.
Inspired from "Fast connected-component labeling" by Lifeng He, Yuyan Chao, Kenji Suzuki and Kesheng Wu.
ExceptionIO | cannot open image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
[in] | tree | The tree name add the block to |
Definition at line 1640 of file CRNBlock.cpp.
void Block::FilterBorders | ( | const String & | tree, |
size_t | margin | ||
) |
Filters a child tree.
Filters a child tree. Each child block within a margin close to the borders is removed
ExceptionNotFound | tree not found |
[in] | tree | The tree name |
[in] | margin | The minimal distance to the border |
Definition at line 2187 of file CRNBlock.cpp.
void Block::FilterHeightRatio | ( | const String & | tree, |
double | ratio | ||
) |
Filters a child tree.
Filters a child tree. Each child block with Height > ratio * Width is removed.
ExceptionNotFound | tree not found |
ExceptionDomain | ratio is negative or null |
[in] | tree | The tree name |
[in] | ratio | The maximal Height/Width ratio allowed (must be >0) |
Definition at line 2244 of file CRNBlock.cpp.
void Block::FilterMaxAnd | ( | const String & | tree, |
size_t | maxw, | ||
size_t | maxh | ||
) |
Filters a child tree.
Filters a child tree. Each child block with width and height greater than the min values is removed.
ExceptionNotFound | tree not found |
[in] | tree | The tree name |
[in] | maxw | The maximal width |
[in] | maxh | The maximal height |
Definition at line 2138 of file CRNBlock.cpp.
void Block::FilterMaxOr | ( | const String & | tree, |
size_t | maxw, | ||
size_t | maxh | ||
) |
Filters a child tree.
Filters a child tree. Each child block with width or height greater than the min values is removed.
ExceptionNotFound | tree not found |
[in] | tree | The tree name |
[in] | maxw | The maximal width |
[in] | maxh | The maximal height |
Definition at line 2163 of file CRNBlock.cpp.
void Block::FilterMinAnd | ( | const String & | tree, |
size_t | minw, | ||
size_t | minh | ||
) |
Filters a child tree.
Filters a child tree. Each child block with width and height lesser than the min values is removed.
ExceptionNotFound | tree not found |
[in] | tree | The tree name |
[in] | minw | The minimal width |
[in] | minh | The minimal height |
Definition at line 2080 of file CRNBlock.cpp.
void Block::FilterMinOr | ( | const String & | tree, |
size_t | minw, | ||
size_t | minh | ||
) |
Filters a child tree.
Filters a child tree. Each child block with width or height lesser than the min values is removed.
ExceptionNotFound | tree not found |
[in] | tree | The tree name |
[in] | minw | The minimal width |
[in] | minh | The minimal height |
Definition at line 2113 of file CRNBlock.cpp.
void Block::FilterWidthRatio | ( | const String & | tree, |
double | ratio | ||
) |
Filters a child tree.
Filters a child tree. Each child block with Width > ratio * Height is removed.
ExceptionNotFound | tree not found |
ExceptionDomain | ratio is negative or null |
[in] | tree | The tree name |
[in] | ratio | The maximal Width/Height ratio allowed (must be >0). |
Definition at line 2215 of file CRNBlock.cpp.
void Block::FlushAll | ( | bool | recursive = false | ) |
Frees the local buffers.
Frees all buffers
[in] | recursive | shall childrens' buffer be flushed? |
Definition at line 1327 of file CRNBlock.cpp.
void Block::FlushBW | ( | bool | recursive = false | ) |
Frees the local b&w buffer.
Frees the local b&w buffer
[in] | recursive | shall childrens' buffer be flushed? |
Definition at line 1385 of file CRNBlock.cpp.
void Block::FlushGradient | ( | bool | recursive = false | ) |
Frees the local gradient buffer.
Frees the local gradient buffer
[in] | recursive | shall childrens' buffer be flushed? |
Definition at line 1407 of file CRNBlock.cpp.
void Block::FlushGray | ( | bool | recursive = false | ) |
Frees the local gray buffer.
Frees the local gray buffer
[in] | recursive | shall childrens' buffer be flushed? |
Definition at line 1363 of file CRNBlock.cpp.
void Block::FlushRGB | ( | bool | recursive = false | ) |
Frees the local RGB buffer.
Frees the local RGB buffer
[in] | recursive | shall childrens' buffer be flushed? |
Definition at line 1341 of file CRNBlock.cpp.
|
inlinenoexcept |
Gets the absolute bounding box of the block.
Definition at line 71 of file CRNBlock.h.
SImageBW Block::GetBW | ( | bool | create = true | ) |
Returns a pointer to the local b&w buffer.
Returns a pointer to the local b&w buffer. Creates the buffer if non existent.
ExceptionIO | cannot open image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
[in] | create | Shall the buffer be created from a rgb or gray one? default = true. |
Definition at line 932 of file CRNBlock.cpp.
SBlock Block::GetChild | ( | const String & | tree, |
size_t | num | ||
) |
Gets a block of a child tree.
Gets a block of a child tree
ExceptionNotFound | tree not found |
ExceptionDomain | index out of bounds |
[in] | tree | The tree name |
[in] | num | The index of the subblock |
Definition at line 1897 of file CRNBlock.cpp.
SCBlock Block::GetChild | ( | const String & | tree, |
size_t | num | ||
) | const |
Gets a block of a child tree.
Gets a block of a child tree
ExceptionNotFound | tree not found |
ExceptionDomain | index out of bounds |
[in] | tree | The tree name |
[in] | num | The index of the subblock |
Definition at line 1919 of file CRNBlock.cpp.
Gets a block of a child tree.
Gets a block of a child tree
ExceptionNotFound | tree or block not found |
[in] | tree | The tree name |
[in] | name | The name of the subblock |
Definition at line 1944 of file CRNBlock.cpp.
Gets a block of a child tree.
Gets a block of a child tree
ExceptionNotFound | tree or block not found |
[in] | tree | The tree name |
[in] | name | The name of the subblock |
Definition at line 1969 of file CRNBlock.cpp.
SImageGradient Block::GetGradient | ( | bool | create = true , |
double | sigma = -1 , |
||
size_t | diffusemaxiter = 0 , |
||
double | diffusemaxdiv = std::numeric_limits<double>::max() |
||
) |
Returns a pointer to the local gradient buffer.
Returns a pointer to the local gradient buffer.
ExceptionIO | cannot open image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
[in] | create | Shall the buffer be created from a gray or b&w one? default = true. |
[in] | sigma | The standard deviation of the gaussian core used to apply the gradient. default = 0.5 |
[in] | diffusemaxiter | maximal number of iterations of the diffusion |
[in] | diffusemaxdiv | maximal divergence to allow modification for each pixel during the diffusion |
Definition at line 1205 of file CRNBlock.cpp.
SImageGray Block::GetGray | ( | bool | create = true | ) |
Returns a pointer to the local gray buffer.
Returns a pointer to the local gray buffer. Creates the buffer if non existent.
ExceptionIO | cannot open image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
[in] | create | Shall the buffer be created from a rgb one? default = true. |
Definition at line 862 of file CRNBlock.cpp.
size_t Block::GetNbChildren | ( | const String & | tree | ) | const |
Gets the number of blocks in a child tree.
Gets the number of blocks in a child tree
ExceptionInvalidArgument | tree not found |
[in] | tree | The tree name |
Definition at line 1877 of file CRNBlock.cpp.
|
inline |
Gets a reference to the parent of the block.
Definition at line 80 of file CRNBlock.h.
|
inline |
Gets a reference to the parent of the block.
Definition at line 82 of file CRNBlock.h.
|
inlinenoexcept |
Gets the name of the parent tree of the block.
Definition at line 86 of file CRNBlock.h.
Rect Block::GetRelativeBBox | ( | ) | const |
Gets the relative bounding box of the block.
Gets the relative bounding box of the block
Definition at line 316 of file CRNBlock.cpp.
SImageRGB Block::GetRGB | ( | ) |
Returns a pointer to the local RGB buffer.
Returns a pointer to the local RGB buffer.
ExceptionIO | cannot open image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
Definition at line 795 of file CRNBlock.cpp.
WBlock Block::GetTop | ( | ) |
Gets a reference to the topmost parent of the block.
Gets a reference to the topmost parent of the block
Definition at line 2480 of file CRNBlock.cpp.
|
inline |
Returns a list of children. Can be used with CRN_FOREACH.
Definition at line 212 of file CRNBlock.h.
|
inline |
Returns a list of children. Can be used with CRN_FOREACH.
Definition at line 218 of file CRNBlock.h.
void Block::GetTreeMeans | ( | const String & | tree, |
double * | mwidth, | ||
double * | mheight, | ||
double * | marea | ||
) | const |
Returns the mean width, height and area of the subblocks.
Returns the mean width, height and area of the subblocks
ExceptionInvalidArgument | tree not found |
[in] | tree | the name of the block tree |
[out] | mwidth | the mean width |
[out] | mheight | the mean height |
[out] | marea | the mean area |
Definition at line 1845 of file CRNBlock.cpp.
std::vector< String > Block::GetTreeNames | ( | ) | const |
Gets the list of the tree names.
Gets the list of the tree names
Definition at line 986 of file CRNBlock.cpp.
bool Block::HasTree | ( | const String & | tname | ) | const |
Checks if a child tree exists.
Checks if a child tree exists
[in] | tname | The name of the tree to check |
Definition at line 1172 of file CRNBlock.cpp.
bool Block::IsParent | ( | const Block & | b | ) | const |
Checks if a block is a parent of current.
Checks ascendency between two blocks.
[in] | b | the candidate parent |
Definition at line 2495 of file CRNBlock.cpp.
Block::masked_pixel_iterator Block::MaskedPixelBegin | ( | const String & | tree, |
size_t | num, | ||
pixel::BW | mask_value = pixel::BWBlack |
||
) |
Returns a masked iterator on the first pixel of the block.
Returns an iterator on the first pixel of the block
ExceptionInvalidArgument | tree not found |
ExceptionDomain | index out of bounds |
ExceptionIO | cannot open bw image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
[in] | tree | the name of the subblock tree |
[in] | num | the index tof the block to iterate |
[in] | mask_value | crn::pixel::BWWhite or crn::pixel::BWBlack |
Definition at line 2600 of file CRNBlock.cpp.
Block::masked_pixel_iterator Block::MaskedPixelBegin | ( | const SBlock & | b, |
pixel::BW | mask_value = pixel::BWBlack |
||
) |
Returns a masked iterator after the last pixel of the block.
Returns an iterator on the first pixel of the block
ExceptionInvalidArgument | tree not found |
ExceptionIO | cannot open bw image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
[in] | b | the subblock to iterate |
[in] | mask_value | crn::pixel::BWWhite or crn::pixel::BWBlack |
Definition at line 2627 of file CRNBlock.cpp.
Block::masked_pixel_iterator Block::MaskedPixelEnd | ( | const String & | tree, |
size_t | num, | ||
pixel::BW | mask_value = pixel::BWBlack |
||
) |
Returns a masked iterator on the first pixel of the block.
Returns an iterator after the last pixel of the block
ExceptionInvalidArgument | tree not found |
ExceptionDomain | index out of bounds |
[in] | tree | the name of the subblock tree |
[in] | num | the index tof the block to iterate |
[in] | mask_value | crn::pixel::BWWhite or crn::pixel::BWBlack |
Definition at line 2649 of file CRNBlock.cpp.
Block::masked_pixel_iterator Block::MaskedPixelEnd | ( | const SBlock & | b, |
pixel::BW | mask_value = pixel::BWBlack |
||
) |
Returns a masked iterator after the last pixel of the block.
Returns an iterator after the last pixel of the block
ExceptionInvalidArgument | null block or block is not a child |
[in] | b | the subblock to iterate |
[in] | mask_value | crn::pixel::BWWhite or crn::pixel::BWBlack |
Definition at line 2671 of file CRNBlock.cpp.
bool Block::MergeChildren | ( | const String & | tree, |
double | overlap, | ||
ImageIntGray * | imap = nullptr |
||
) |
Merges overlapping children in a tree.
Merges overlapping children in a tree. Once it is done, it's possible that a merged block resulting from overlapping ones overlaps another merged block. In order to make sure that the result contains no overlapping blocks, this method should be run until it returns false (until the re is no more overlapping blocks).
ExceptionNotFound | tree not found |
ExceptionDomain | overlap is negative |
[in] | tree | The tree name |
[in] | overlap | The maximal overlapping to avoid merging. ie: overlap=0 means all overlapping children will be merged. overlap=1 means only fully overlaid children will be merged. |
[in] | imap | the map image to update (can be null) |
Definition at line 2279 of file CRNBlock.cpp.
void Block::MergeSiblings | ( | const String & | tree, |
size_t | index1, | ||
size_t | index2, | ||
ImageIntGray * | imap = nullptr |
||
) |
Merges two subblocks.
Merges two subblocks.
ExceptionNotFound | tree not found |
ExceptionLogic | identical indexes |
ExceptionDomain | index out of bounds |
[in] | tree | the name of the tree |
[in] | index1 | the index of the child that will be updated |
[in] | index2 | the index of the child that will be removed |
[in] | imap | the map image to update (can be nullptr) |
Definition at line 2385 of file CRNBlock.cpp.
void Block::MergeSiblings | ( | const String & | tree, |
Block & | sb1, | ||
Block & | sb2, | ||
ImageIntGray * | imap = nullptr |
||
) |
Merges two subblocks.
Merges two subblocks.
ExceptionNotFound | tree or block not found |
[in] | tree | the name of the tree |
[in] | sb1 | |
[in] | sb2 | |
[in] | imap | the map image to update (can be nullptr) |
Definition at line 2446 of file CRNBlock.cpp.
Top block creator.
Constructor for a top Block
ExceptionInvalidArgument | null image or unsupported image type (BW, Gray nor RGB) |
[in] | src | The source image of the top block |
[in] | nam | the name of the new block |
Definition at line 46 of file CRNBlock.cpp.
Constructor from filenames.
Constructor from filenames
ExceptionIO | XML file exists but cannot be accessed or has invalid structure |
ExceptionRuntime | the XML file does not fit the block's image |
ExceptionIO | cannot open image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
[in] | ifname | image filename |
[in] | xfname | xml filename |
[in] | nam | the name of the new block |
Definition at line 114 of file CRNBlock.cpp.
Block::pixel_iterator Block::PixelBegin | ( | const String & | tree, |
size_t | num | ||
) | const |
Returns an iterator on the first pixel of the block.
Returns an iterator on the first pixel of the block
ExceptionInvalidArgument | tree not found |
ExceptionDomain | index out of bounds |
[in] | tree | the name of the subblock tree |
[in] | num | the index of the block to iterate |
Definition at line 2515 of file CRNBlock.cpp.
Block::pixel_iterator Block::PixelBegin | ( | const SBlock & | b | ) | const |
Returns an iterator on the first pixel of the block.
Returns an iterator on the first pixel of the block
ExceptionInvalidArgument | null block or block is not a child |
[in] | b | the subblock to iterate |
Definition at line 2538 of file CRNBlock.cpp.
Block::pixel_iterator Block::PixelEnd | ( | const String & | tree, |
size_t | num | ||
) | const |
Returns an iterator after the last pixel of the block.
Returns an iterator after the last pixel of the block
ExceptionInvalidArgument | tree not found |
ExceptionDomain | index out of bounds |
[in] | tree | the name of the subblock tree |
[in] | num | the index tof the block to iterate |
Definition at line 2558 of file CRNBlock.cpp.
Block::pixel_iterator Block::PixelEnd | ( | const SBlock & | b | ) | const |
Returns an iterator after the last pixel of the block.
Returns an iterator after the last pixel of the block
ExceptionInvalidArgument | null block or block is not a child |
[in] | b | the subblock to iterate |
Definition at line 2578 of file CRNBlock.cpp.
void Block::ReloadImage | ( | ) |
Reloads the image.
Reloads the image
ExceptionIO | cannot open image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
Definition at line 1304 of file CRNBlock.cpp.
void Block::RemoveChild | ( | const String & | tree, |
size_t | num | ||
) |
Removes a block of a child tree.
Removes a block of a child tree. The possible shared pointers remaining on the block should not be used after the removal.
ExceptionNotFound | tree not found |
ExceptionDomain | index ouf of bounds |
[in] | tree | The tree name |
[in] | num | The index of the subblock |
Definition at line 1995 of file CRNBlock.cpp.
Removes a block of a child tree.
Removes a block of a child tree. The possible shared pointers remaining on the block should not be used after the removal.
ExceptionNotFound | tree or block not found |
[in] | tree | The tree name |
[in] | name | The name of the subblock |
Definition at line 2019 of file CRNBlock.cpp.
void Block::RemoveChild | ( | const String & | tree, |
SBlock | b | ||
) |
Removes a block of a child tree.
Removes the current block of a child tree. The possible shared pointers remaining on the block should not be used after the removal.
ExceptionNotFound | tree or block not found |
[in] | tree | The tree name |
[in] | b | The block |
Definition at line 2034 of file CRNBlock.cpp.
void Block::RemoveChildren | ( | const String & | tree, |
const std::set< SBlock > & | toremove | ||
) |
Removes a set of blocks from a child tree.
Removes a set of blocks from a child tree
ExceptionNotFound | tree not found |
[in] | tree | the tree to prune |
[in] | toremove | the list of blocks to remove |
Definition at line 2058 of file CRNBlock.cpp.
void Block::RemoveTree | ( | const String & | tname | ) |
Deletes a child tree.
Deletes a child tree
ExceptionNotFound | tree not found |
[in] | tname | The tree to erase |
Definition at line 1187 of file CRNBlock.cpp.
void Block::Save | ( | const Path & | fname | ) |
Saves the child trees into a file.
Saves the child trees into a file.
ExceptionInvalidArgument | empty file name |
ExceptionIO | cannot save XML file |
ExceptionRuntime | error creating the file |
[in] | fname | The file to create. |
Definition at line 1004 of file CRNBlock.cpp.
|
inline |
Saves the child trees into the default file.
Saves the child trees into the default file
ExceptionInvalidArgument | empty file name |
ExceptionIO | cannot save XML file |
Definition at line 143 of file CRNBlock.h.
void Block::SetAbsoluteBBox | ( | const Rect & | newbox | ) |
Sets the absolute bounding box of the block.
Sets the absolute bounding box.
If it overflows the topmost parent's bounding box, we truncate the box. A topmost block's bounding box cannot be set.
ExceptionLogic | the block is the topmost block |
ExceptionInvalidArgument | uninitialized bounding box |
ExceptionDimension | bounding box is out of parent's bounding box |
[in] | newbox | the new absolute bounding box |
Definition at line 254 of file CRNBlock.cpp.
|
inline |
Sets the default filename of the block.
Definition at line 68 of file CRNBlock.h.
void Block::SetRelativeBBox | ( | Rect | newbox | ) |
Sets the absolute bounding box of the block.
Sets the relative bounding box.
If it overflows the topmost parent's bounding box, we truncate the box. A topmost block's bounding box cannot be set.
ExceptionLogic | the block is the topmost block |
ExceptionInvalidArgument | uninitialized bounding box |
ExceptionDimension | bounding box is out of parent's bounding box |
[in] | newbox | the new relative bounding box |
Definition at line 300 of file CRNBlock.cpp.
Sorts a child tree.
Sorts a child tree
ExceptionInvalidArgument | tree not found |
ExceptionDomain | invalid direction |
[in] | name | the name of the child tree to sort |
[in] | direction | the direction (Direction::LEFT for left to right, Direction::TOP for top to bottom, Direction::RIGHT for right to left or Direction::BOTTOM for bottom to top). Use only one direction at a time, don't try to combinate the directions with the | operator. |
Definition at line 2691 of file CRNBlock.cpp.
void Block::SubstituteBW | ( | const SImageBW & | img | ) |
Substitutes the BW buffer with a new one.
Substitutes the BW buffer with a new image.
If a buffer exists, it will be freed.
If the substitution succeeds, the block will keep the reference to the new image and will free it himself.
ExceptionDimension | the images do no have the same size |
[in] | img | the new image to use |
Definition at line 1495 of file CRNBlock.cpp.
void Block::SubstituteGradient | ( | const SImageGradient & | img | ) |
Substitutes the Gradient buffer with a new one.
Substitutes the Gradient buffer with a new image.
If a buffer exists, it will be freed.
If the substitution succeeds, the block will keep the reference to the new image and will free it himself.
ExceptionDimension | the images do no have the same size |
[in] | img | the new image to use |
Definition at line 1525 of file CRNBlock.cpp.
void Block::SubstituteGray | ( | const SImageGray & | img | ) |
Substitutes the Gray buffer with a new one.
Substitutes the Gray buffer with a new image.
If a buffer exists, it will be freed.
If the substitution succeeds, the block will keep the reference to the new image and will free it himself.
ExceptionDimension | the images do no have the same size |
[in] | img | the new image to use |
Definition at line 1465 of file CRNBlock.cpp.
void Block::SubstituteRGB | ( | const SImageRGB & | img | ) |
Substitutes the RGB buffer with a new one.
Substitutes the RGB buffer with a new image.
If a buffer exists, it will be freed.
If the substitution succeeds, the block will keep the reference to the new image and will free it himself.
ExceptionDimension | the images do no have the same size |
[in] | img | the new image to use |
Definition at line 1435 of file CRNBlock.cpp.