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