| Rect Functions | |
| Constructors and Destructors | |
| rect | Creates a new Rect or adds a new Rect to a list |
| rectCopy | Makes a copy of a Rect |
| rectDelete | Frees the memory used by a Rect |
| rectFilter | Filter the Rects on the list based on a criteria. |
| rectMaximalWhiteRectangles | An implementation of the algorithm described in “T. |
| rectIsValid | Checks if the Rect is valid (left < right and top < bottom) |
| rectArea | Returns the area of the Rect. |
| rectDistance | Returns the between two Rects |
| rectClosest | Returns the closest Rect to the (x, y) point |
| rectIntersects | Check if the Rects intersect each other |
| rectPointInside | Checks if the passed point is inside the Rect |
| rectRectInside | Checks if a Rect is inside another |
| rectPrint | Prints all the Rects in r preceded by msg |
| Priority Queue Functions | |
| rectPQEnqueue | Enqueue a triple of bound, obstacles and quality |
| rectPQGet | Get the best element of the queue |
| rectPQUpdate | For every element, add new to the obstacles list if new intersects bound |
| rectPQDelete | Delete the priority queue |
Rect *rect( int x1, int y1, int x2, int y2, double fill, Rect * next )
Creates a new Rect or adds a new Rect to a list
| x1 | x coordinate of the top-left corner |
| y1 | y coordinate of the top-left corner |
| x2 | x coordinate of the bottom-right corner |
| y1 | y coordinate of the bottom-right corner |
| fill | indicates how much of the rect is filled (used in some connected components functions |
| next | the next Rect in the list. Pass NULL to create a single Rect |
The Rect created.
Rect *rectFilter( Rect * r, int criteria, double min, double max )
Filter the Rects on the list based on a criteria.
| r | Rects to be filtered |
| criteria | The criteria to be applied. Can be one of FILTER_WIDTH, FILTER_HEIGHT, FILTER_AREA, FILTER_RATIO or FILTER_FILL |
| min | the minimum value allowed. Use -1 to ignore. |
| max | the maximum value allowed. Use -1 to ignore. |
Rect list r containing only the Rects that are allowed. The Rects that do not fill the requirements are freed with rectDelete.
Rect *rectMaximalWhiteRectangles( Rect * bound, Rect * obstacles, int N, double (*quality)(Rect *r) )
An implementation of the algorithm described in “T. M. Breuel. Two algorithms for geometric layout analysis. In Proceedings of the Workshop on Document Analysis Systems, Princeton, NJ, USA, 2002”.
| bound | the area that should be analyzed. Only the obstacles in this area aree going to be considered. |
| obstacles | the obstacles of the document. All the Rects returned MUST NOT intersect any of this Rects |
| N | the maximum number of Rects to find |
| quality | a function that receives a Rect and returns the quality of that Rect. This number is used to classify the Rects and the greater the number the better the Rect is. The area can be used to find the Rect that covers the maximal white area of a document, but other functions can give different results. |
A list with the maximal white rectangles in bound that do not intersect obstacles.
RectPQ *rectPQEnqueue( RectPQ * pq, Rect * bound, Rect * obstacles, double quality )
Enqueue a triple of bound, obstacles and quality
| pq | Priorioty queue to add the element |
| bound | the bound of the element |
| obstacles | obstacles in the element’s bound |
| quality | quality of the element |
The updated priority queue
RectPQ *rectPQGet( RectPQ * pq, Rect ** bound, Rect ** obstacles, double * q )
Get the best element of the queue
| pq | Priorioty queue to get the element |
| bound | pointer to the variable to store the element’s bound |
| obstacles | pointer to the variable to store the element’s obstacles |
| quality | pointer to the variable to store the element’s quality |
The updated priority queue
Creates a new Rect or adds a new Rect to a list
Rect *rect( int x1, int y1, int x2, int y2, double fill, Rect * next )
Makes a copy of a Rect
Rect *rectCopy( Rect * r )
Frees the memory used by a Rect
void rectDelete( Rect * r )
Filter the Rects on the list based on a criteria.
Rect *rectFilter( Rect * r, int criteria, double min, double max )
An implementation of the algorithm described in “T.
Rect *rectMaximalWhiteRectangles( Rect * bound, Rect * obstacles, int N, double (*quality)(Rect *r) )
Checks if the Rect is valid (left < right and top < bottom)
int rectIsValid( Rect * r )
Returns the area of the Rect.
double rectArea( Rect * r )
Returns the between two Rects
double rectDistance( Rect * r1, Rect * r2 )
Returns the closest Rect to the (x, y) point
Rect *rectClosest( Rect * r, int x, int y )
Check if the Rects intersect each other
int rectIntersects( Rect * r1, Rect * r2 )
Checks if the passed point is inside the Rect
int rectPointInside( Rect * r, int x, int y )
Checks if a Rect is inside another
int rectRectInside( Rect * r, Rect * r2 )
Prints all the Rects in r preceded by msg
void rectPrint( char * msg, Rect * r )
Enqueue a triple of bound, obstacles and quality
RectPQ *rectPQEnqueue( RectPQ * pq, Rect * bound, Rect * obstacles, double quality )
Get the best element of the queue
RectPQ *rectPQGet( RectPQ * pq, Rect ** bound, Rect ** obstacles, double * q )
For every element, add new to the obstacles list if new intersects bound
RectPQ *rectPQUpdate( RectPQ * pq, Rect * new )
Delete the priority queue
void rectPQDelete( RectPQ * pq )