I guess that Juan knows a better way to do this... but meanwhile, this is a method to create any structure
First, you need to create a new class, "Structure" works fine. Inside, define an array of uint8 of three dimensions (row, column and way) (it may works also with pcl_bool variables).
Define a function that reads each element (returns false or true), another to get the size (number of rows or columns... should be a square), and to get the number of ways.
Now, you have to create another class, that inherits the properties of StructuringElement. This class has access to the contents of the class Structure you created before.
This is an example from the source code of MorphologicalTransform
class MorphologicalTransformStructure : public StructuringElement
{
public:
MorphologicalTransformStructure( const MorphologicalTransformInstance& M ) :
StructuringElement(), structure( M.GetStructure() )
{
Resize( structure.Size() );
}
virtual int NumberOfWays() const
{
return structure.NumberOfWays();
}
virtual bool ElementExists( int i, int j, int k ) const // row, col, way
{
return structure.Element( k, j, i );
}
private:
const Structure& structure;
};
Now you may just use that class:
MorphologicalTransformStructure S( M ); //this is the class we created above... M is the instance of the MorphologicalTransform process... you may rewrite the class to create the structure you want, directly reading an array.
MorphologicalTransform T;
T.SetStructure( S );
It is quite a convoluted process to set the values... but I cannot find anything easier... hope this helps.