Image Component Library (ICL)
|
Utility class that helps applying UnaryOps one after another. More...
#include <UnaryOpPipe.h>
Public Member Functions | |
UnaryOpPipe () | |
create an empty pipe | |
~UnaryOpPipe () | |
Destructor. | |
void | add (UnaryOp *op, core::ImgBase *im=0) |
appends a new op on the end of this pipe (ownership of op and im is passed to the pipe) | |
UnaryOpPipe & | operator<< (UnaryOp *op) |
stream based wrapper for the add function (calls add(op,0)) | |
virtual void | apply (const core::ImgBase *src, core::ImgBase **dst) |
applies all ops sequentially | |
virtual const core::ImgBase * | apply (const core::ImgBase *src) |
This function is reimplemented here; it uses getLastImage() as destination image. | |
int | getLength () const |
returns the number of contained ops | |
UnaryOp *& | getOp (int i) |
returns the op at given index | |
core::ImgBase *& | getImage (int i) |
returns the result buffer image at given index | |
core::ImgBase *& | getLastImage () |
returns the last image (which is not used by default) | |
Private Attributes | |
std::vector< UnaryOp * > | ops |
Internal buffer of ops. | |
std::vector< core::ImgBase * > | ims |
Internal buffer of result images. |
Utility class that helps applying UnaryOps one after another.
Consider a default computer vision system, which has some preprocessing steps in the following operation order:
To facilitate this, you can easily use a UnaryOpPipe, which internally creates a queue of UnaryOp instances and their individual result images (as ImgBase*). Once you have created this Pipe under a certain name (e.g. "MyProprocessor") you can easily add or remove specific preprocessing steps, without having to consider fall-outs elsewhere in your code.
Take a look on the following example:
#include <ICLQt/Quick.h> #include <ICLFilter/UnaryOpPipe.h> #include <ICLFilter/ScaleOp.h> #include <ICLFilter/WeightedSumOp.h> #include <ICLFilter/UnaryCompareOp.h> #include <ICLFilter/MorphologicalOp.h> int main(){ // create an input image (the nice parrot here!) ImgQ inputImage = create("parrot"); // create a weight vector (used later on by an instance of the WeightedSumOp class) vector<icl64f> weights(3); weights[0] = 0.2; weights[1] = 0.5; weights[0] = 0.3; // create the empty pipe UnaryOpPipe pipe; // add the UnaryOp's in the correct order pipe << new ScaleOp(0.25,0.25) << new WeightedSumOp(weights) << new UnaryCompareOp(UnaryCompareOp::gt,110) << new MorphologicalOp(MorphologicalOp::erode3x3); // apply this pipe on the source image (use the last image as destination) const ImgBase *res = pipe.apply(&inputImage); // show the result using ICLQuick show(cvt(res)); }
create an empty pipe
Destructor.
void icl::filter::UnaryOpPipe::add | ( | UnaryOp * | op, |
core::ImgBase * | im = 0 |
||
) |
appends a new op on the end of this pipe (ownership of op and im is passed to the pipe)
virtual void icl::filter::UnaryOpPipe::apply | ( | const core::ImgBase * | src, |
core::ImgBase ** | dst | ||
) | [virtual] |
applies all ops sequentially
Implements icl::filter::UnaryOp.
virtual const core::ImgBase* icl::filter::UnaryOpPipe::apply | ( | const core::ImgBase * | src | ) | [virtual] |
This function is reimplemented here; it uses getLastImage() as destination image.
Reimplemented from icl::filter::UnaryOp.
core::ImgBase*& icl::filter::UnaryOpPipe::getImage | ( | int | i | ) |
returns the result buffer image at given index
returns the last image (which is not used by default)
This image is only used, if it is given a 2nd parameter to the apply function
MyPipe.apply(mySourceImagePtr,&(MyPipe.getLastImage());
int icl::filter::UnaryOpPipe::getLength | ( | ) | const |
returns the number of contained ops
UnaryOp*& icl::filter::UnaryOpPipe::getOp | ( | int | i | ) |
returns the op at given index
UnaryOpPipe& icl::filter::UnaryOpPipe::operator<< | ( | UnaryOp * | op | ) | [inline] |
stream based wrapper for the add function (calls add(op,0))
ownership of op is passed to the pipe
std::vector<core::ImgBase*> icl::filter::UnaryOpPipe::ims [private] |
Internal buffer of result images.
std::vector<UnaryOp*> icl::filter::UnaryOpPipe::ops [private] |
Internal buffer of ops.