Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Attributes
icl::filter::UnaryOpPipe Class Reference

Utility class that helps applying UnaryOps one after another. More...

#include <UnaryOpPipe.h>

Inheritance diagram for icl::filter::UnaryOpPipe:
icl::filter::UnaryOp icl::utils::Configurable

List of all members.

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)
UnaryOpPipeoperator<< (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::ImgBaseapply (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.

Detailed Description

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:

  1. resize the image to a given size
  2. calculate a feature map (e.g. a weighted sum of the color channels)
  3. binarize the feature map
  4. apply some morphological operation on this feature map

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));
        }

Constructor & Destructor Documentation

create an empty pipe

Destructor.


Member Function Documentation

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.

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());

returns the number of contained ops

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


Member Data Documentation

Internal buffer of result images.

std::vector<UnaryOp*> icl::filter::UnaryOpPipe::ops [private]

Internal buffer of ops.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines