Data processing classes

There is a large class of AMMA classes which perform some operation on a single input object and generate a single output object. For example, a 2-D spatial filter takes in an image and generates a filtered version.

Many of these classes have been designed with the same programming interface. This interface can be used in one of two ways, illustrated here using an image filtering operation:

  1. Construct the filter, then use the Apply() operator to apply it (useful if the same filter is to be applied to many images):
        IPMeanC filt(2,3); // convolution that computes mean over 2x3 patch
        out = g.Apply(in);
    	
  2. Use the piping system to construct and apply the filter in one go (useful if many filters are to be sequentially applied to a single image):
        in >> IPMeanC(2,3) >> out;
    	
    With this usage, the operators can be conveniently cascaded:
        in >> IPRunLengthC(2,3) >> IPRunLengthC(5,7) >> IPRunLengthC(8,4) >> out;
    	
    - this will apply 3 different run-length filters to the image in, piping the result into out.
All classes that inherit DPProcessC can be used in either fashion.

Here is a complete sample program illustrating the two usages:

#include "amma/Image/IPRunLength.hh"
#include "amma/DP/ComposeSE.hh"  // only needed for method 2, i.e. using ">>"

int main()
{
  using namespace DPComposeSE;   // only needed for method 2, i.e. using ">>"
  
  ImageC in(7,12); in.Fill(1); in[2][4]=7;
  ImageC out;
  
  // method 1:
  IPRunLengthC f(2,3);
  out = f.Apply(in);

  // method 2:
  in >> IPRunLengthC(2,3) >> out;
  // alternatively:
  ImageC alt = in >> IPRunLengthC(2,3);
}
    

Bill Christmas
Last modified: Fri Sep 3 11:09:17 BST 1999