Image Component Library (ICL)
|
Utility class for image flood filling. More...
#include <FloodFiller.h>
Classes | |
struct | DefaultCriterion |
predefined criterion for simple reference-value based filling for 1-channel images More... | |
struct | ReferenceColorCriterion |
predefined criterion for simple reference-value based filling for 3-channel images More... | |
struct | Result |
result structure, returned by the 'apply' methods More... | |
Public Member Functions | |
const Result & | apply (const core::ImgBase *image, const utils::Point &seed, double referenceValue, double threshold) |
flood-fills the given grayscale image starting from given seed point. | |
const Result & | applyColor (const core::ImgBase *image, const utils::Point &seed, double refR, double refG, double refB, double threshold) |
flood-fills the given 3-channel image starting from the given seed point | |
template<class T , class Criterion > | |
const Result & | applyGeneric (const core::Img< T > &image, const utils::Point &seed, Criterion crit) |
generic grayscale image floodfilling using an arbitrary filling criterion | |
template<class T , class Criterion3Channels > | |
const Result & | applyColorGeneric (const core::Img< T > &image, const utils::Point &seed, Criterion3Channels crit) |
generic floodfilling algorithm for 3-channel color images | |
Public Attributes | |
struct icl::cv::FloodFiller::Result | result |
Private Member Functions | |
utils::Rect | prepare (const utils::Size &imageSize, const utils::Point &seed) |
internal utility method | |
Private Attributes | |
std::vector< utils::Point > | futurePoints |
internal list of to-be-processed points |
Utility class for image flood filling.
The flood filler implements a generic flood filling algorithm. Starting with a seed region that contains just a single point, the flood filler will collect all adjacent pixels of this region recursively that meet a certain criterion. The criterion is the template parameter of the FloodFiller's icl::FloodFiller::applyGeneric template method. For convenience, the most common criterions are pre-coded and directly usable by calling the non-template methods icl::FloodFiller::apply and icl::FloodFiller::applyColor.
The flood filler provides separate implementations for 1- and 3-channel images. The 3-channel image methods have the *Color-ending: icl::FloodFiller::applyColor and icl::FloodFiller::applyColorGeneric
The floodfilling algorithm uses the 8-Pixel neighbourhood of each pixel.
The floodfilling algorithm is implemented in an iterative manner. It uses a mask, which is initialized with zero and set to 1 for already processed pixels. In addition, a to-be-processed-pixels queue is used. In order to speed up the queue implementation, a static and large enough array two pointers n (next to-be-processed point) and e (end of to-be-processed-points) are used. At start, only the seed point is put into the queue. Now while there are pixels in the queue, each of the 8 neighbours, that have not been processed earlier and that match the filling criterion are filled and put into the queue.
const Result& icl::cv::FloodFiller::apply | ( | const core::ImgBase * | image, |
const utils::Point & | seed, | ||
double | referenceValue, | ||
double | threshold | ||
) |
flood-fills the given grayscale image starting from given seed point.
Image pixels are filled if their pixel value difference to the given referenceValue is less then the given threshold
const Result& icl::cv::FloodFiller::applyColor | ( | const core::ImgBase * | image, |
const utils::Point & | seed, | ||
double | refR, | ||
double | refG, | ||
double | refB, | ||
double | threshold | ||
) |
flood-fills the given 3-channel image starting from the given seed point
Here, the fill-criterion is the euclidian distance to the given (refR,refG,regB) reference color, which must be less than the given threshold
const Result& icl::cv::FloodFiller::applyColorGeneric | ( | const core::Img< T > & | image, |
const utils::Point & | seed, | ||
Criterion3Channels | crit | ||
) | [inline] |
generic floodfilling algorithm for 3-channel color images
the criterion function or functor gets all 3-channel pixel values as arguments. Take a look at the icl::Floodfiller::ReferenceColorCriterion class template for more details.
const Result& icl::cv::FloodFiller::applyGeneric | ( | const core::Img< T > & | image, |
const utils::Point & | seed, | ||
Criterion | crit | ||
) | [inline] |
generic grayscale image floodfilling using an arbitrary filling criterion
The criterion-function or functor is evaluated by giving it pixel values Take a look at the icl::FloodFiller::DefaultCriterion class for more details.
utils::Rect icl::cv::FloodFiller::prepare | ( | const utils::Size & | imageSize, |
const utils::Point & | seed | ||
) | [private] |
internal utility method
std::vector<utils::Point> icl::cv::FloodFiller::futurePoints [private] |
internal list of to-be-processed points