|
| ChamferOp (icl32s horizontalAndVerticalNeighbourDistance=3, icl32s diagonalNeighborDistance=4, int scaleFactor=1, bool scaleUpResult=true) |
| Creates a new ChampferOp object with given distances for adjacent image pixels. More...
|
|
virtual | ~ChamferOp () |
| destructor More...
|
|
virtual void | apply (const core::ImgBase *poSrc, core::ImgBase **ppoDst) |
| apply function More...
|
|
virtual void | apply (const core::ImgBase *operand1, core::ImgBase **dst)=0 |
| Import unaryOps apply function without destination image. More...
|
|
virtual const core::ImgBase * | apply (const core::ImgBase *src) |
| Import unaryOps apply function without destination image. More...
|
|
| UnaryOp () |
| Explicit empty constructor. More...
|
|
| UnaryOp (const UnaryOp &other) |
| Explicit copy constructor. More...
|
|
UnaryOp & | operator= (const UnaryOp &other) |
| Explicit declaration of the assignment operator. More...
|
|
virtual | ~UnaryOp () |
| Destructor. More...
|
|
virtual ICL_DEPRECATED void | applyMT (const core::ImgBase *operand1, core::ImgBase **dst, unsigned int nThreads) |
| apply function for multithreaded filtering (currently even slower than using one thread) More...
|
|
virtual const core::ImgBase * | apply (const core::ImgBase *src) |
| applys the filter usign an internal buffer as output image More...
|
|
void | operator() (const core::ImgBase *src, core::ImgBase **dst) |
| function operator (alternative for apply(src,dst) More...
|
|
const core::ImgBase * | operator() (const core::ImgBase *src) |
| function operator for the implicit destination apply(src) call More...
|
|
const core::ImgBase & | operator() (const core::ImgBase &src) |
| reference based function operator More...
|
|
void | setClipToROI (bool bClipToROI) |
| sets if the image should be clip to ROI or not More...
|
|
void | setCheckOnly (bool bCheckOnly) |
| sets if the destination image should be adapted to the source, or if it is only checked if it can be adapted. More...
|
|
bool | getClipToROI () const |
| returns the ClipToROI status More...
|
|
bool | getCheckOnly () const |
| returns the CheckOnly status More...
|
|
virtual void | setPropertyValue (const std::string &propertyName, const utils::Any &value) |
| sets value of a property (always call call_callbacks(propertyName) or Configurable::setPropertyValue) More...
|
|
virtual | ~Configurable () |
| virtual destructor More...
|
|
| Configurable (const Configurable &other) |
| Copy constructor. More...
|
|
Configurable & | operator= (const Configurable &other) |
| Assignment operator. More...
|
|
void | setConfigurableID (const std::string &ID) |
| sets the ID of this configurable More...
|
|
const std::string & | getConfigurableID () const |
| returns the configurables static ID More...
|
|
bool | isOrderedFlagSet () const |
| returns whether the ordered flag is set More...
|
|
void | deactivateProperty (const std::string &pattern) |
| adds an additional deativation pattern More...
|
|
void | deleteDeactivationPattern (const std::string &pattern) |
| removed a formerly added deactivation pattern More...
|
|
std::vector< std::string > | getPropertyListWithoutDeactivated () const |
| this returns a filtered list of properties (using all filters added by deactivateProperty) More...
|
|
virtual void | adaptProperty (const std::string &name, const std::string &newType, const std::string &newInfo, const std::string &newToolTip) |
| this function can be used to adapt a specific property afterwards More...
|
|
void | registerCallback (const Callback &cb) |
| add a callback for changed properties More...
|
|
void | removedCallback (const Callback &cb) |
| removes a callback that was registered before More...
|
|
void | syncChangesTo (Configurable *others, int num=1) |
| this can be used to let this instance also apply property changes to others More...
|
|
virtual std::vector< std::string > | getPropertyList () const |
| returns a list of All properties, that can be set using setProperty More...
|
|
virtual bool | supportsProperty (const std::string &propertyName) const |
| base implementation for property check (seaches in the property list) More...
|
|
virtual void | saveProperties (const std::string &filename, const std::vector< std::string > &propertiesToSkip=EMPTY_VEC) const |
| writes all available properties into a file More...
|
|
virtual void | loadProperties (const std::string &filename, const std::vector< std::string > &propertiesToSkip=EMPTY_VEC) |
| reads a camera config file from disc More...
|
|
virtual std::string | getPropertyType (const std::string &propertyName) const |
| get type of property More...
|
|
virtual std::string | getPropertyInfo (const std::string &propertyName) const |
| get information of a properties valid values More...
|
|
virtual Any | getPropertyValue (const std::string &propertyName) const |
| returns the current value of a property or a parameter More...
|
|
virtual std::string | getPropertyToolTip (const std::string &propertyName) const |
| returns the tooltip description for a given property More...
|
|
virtual int | getPropertyVolatileness (const std::string &propertyName) const |
| Returns whether this property may be changed internally. More...
|
|
|
static void | renderModel (const std::vector< utils::Point > &model, core::ImgBase **image, const utils::Size &size, icl32s bg=0, icl32s fg=255, utils::Rect roi=utils::Rect::null) |
| static utility function to convert a model represented by a point set into a binary image More...
|
|
static double | computeDirectedHausdorffDistance (const core::Img32s *chamferImage, const std::vector< utils::Point > &model, hausdorffMetric m=hausdorff_mean, outerROIPenaltyMode pm=noPenalty, icl32s penaltyValue=0) |
| utility function to calculate the directed Hausdorff distance between an image and a model More...
|
|
static double | computeDirectedHausdorffDistance (const core::Img32s *chamferImage, const core::Img32s *modelChamferImage, ChamferOp::hausdorffMetric m, ChamferOp::outerROIPenaltyMode pm=noPenalty, icl32s penaltyValue=0) |
| utility function to calculate the directed Hausdorff distance between an image and a model-image More...
|
|
static double | computeSymmetricHausdorffDistance (const core::Img32s *chamferImageA, const core::Img32s *chamferImageB, hausdorffMetric m=hausdorff_mean, ChamferOp::outerROIPenaltyMode pm=noPenalty, icl32s penaltyValue=0) |
| utility function to calculate the symmetric Hausdorff distance between an two model images More...
|
|
static double | computeSymmetricHausdorffDistance (const std::vector< utils::Point > setA, const utils::Size &sizeA, const utils::Rect &roiA, core::ImgBase **bufferA, const std::vector< utils::Point > setB, const utils::Size &sizeB, const utils::Rect &roiB, core::ImgBase **bufferB, hausdorffMetric m=hausdorff_mean, ChamferOp::outerROIPenaltyMode pm=noPenalty, icl32s penaltyValue=0, ChamferOp coA=ChamferOp(), ChamferOp coB=ChamferOp()) |
| utility function to calculate the symmetric Hausdorff distance between an two point sets More...
|
|
static double | computeSymmeticHausdorffDistance (const core::Img32s *chamferImage, const std::vector< utils::Point > &model, const utils::Size &modelImageSize, const utils::Rect &modelImageROI, core::ImgBase **bufferImageA, core::ImgBase **bufferImageB, hausdorffMetric m=hausdorff_mean, ChamferOp::outerROIPenaltyMode pm=noPenalty, icl32s penaltyValue=0, ChamferOp co=ChamferOp()) |
| utility function to calculate the symmetric Hausdorff distance between an a point set and an already chamfered image More...
|
|
static UnaryOp * | fromString (const std::string &definition) |
| Creates a UnaryOp instance from given string definition. More...
|
|
static std::string | getFromStringSyntax (const std::string &opSpecifier) |
| gives a string syntax description for given opSpecifier More...
|
|
static std::vector< std::string > | listFromStringOps () |
| returns a list of all supported OP_SPEC values for the fromString function More...
|
|
static void | applyFromString (const std::string &definition, const core::ImgBase *src, core::ImgBase **dst) |
| creates, applies and releases a UnaryOp defined by given definition string More...
|
|
static std::string | create_default_ID (const std::string &prefix) |
| this function can be used in subclasses to create a default ID More...
|
|
static Configurable * | get (const std::string &id) |
| returns configurable by given ID More...
|
|
static void | register_configurable_type (const std::string &classname, Function< Configurable * > creator) |
| registers a configurable type More...
|
|
static std::vector< std::string > | get_registered_configurables () |
| returns a list of all registered configurable classnames More...
|
|
static Configurable * | create_configurable (const std::string &classname) |
| creates a configurable by given name More...
|
|
|
static const std::vector< std::string > | EMPTY_VEC |
| used as shortcut – just an empty vector of std::strings More...
|
|
bool | prepare (core::ImgBase **ppoDst, core::depth eDepth, const utils::Size &imgSize, core::format eFormat, int nChannels, const utils::Rect &roi, utils::Time timestamp=utils::Time::null) |
|
virtual bool | prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc) |
| check+adapt destination image to properties of given source image More...
|
|
virtual bool | prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc, core::depth eDepth) |
|
void | addProperty (const std::string &name, const std::string &type, const std::string &info, const Any &value=Any(), const int volatileness=0, const std::string &tooltip=std::string()) |
| This can be used by derived classes to store supported properties in the internal list. More...
|
|
void | addChildConfigurable (Configurable *configurable, const std::string &childPrefix="") |
| This adds another configurable as child. More...
|
|
void | removeChildConfigurable (Configurable *configurable) |
| removes the given child configurable More...
|
|
Property & | prop (const std::string &propertyName) |
| this CAN be used e.g. to store a property value in internal property-list More...
|
|
const Property & | prop (const std::string &propertyName) const |
| this CAN be used e.g. to store a property value in internal property-list More...
|
|
| Configurable (const std::string &ID="", bool ordered=true) |
| create this configurable with given ID More...
|
|
void | call_callbacks (const std::string &propertyName, const Configurable *caller) const |
| calls all registered callbacks More...
|
|
utils::MultiThreader * | m_poMT |
|
std::vector< Callback > | callbacks |
| internally managed list of callbacks More...
|
|
Chamfering Unit.
Chamfering is a procedure called Euclidean-Distance-Transformation (EDT). Input of the Chamfering operation is a binary image. The Chamfering operation creates a map (also called the voronoi surface) which's value at location (x,y) is the distance to the nearest white pixel to the pixel at (x,y) in the image.
Because the calculation of the real euclidean distance to the next white pixel is very expensive , an approximation of the euclidean distance is calculated instead.
A good approximation can be obtained by moving a small (3x2)-mask successively over the image in two cycles, where each pixel is assigned to the minimum of all pixels values in the 3x2-neighborhood plus a distance value which approximates the distance to a neighborhood pixel. The following pseudo-code illustrates the chamfering algorithm:
INPUT := I
OUTPUT := C
D1 := "distance between horizontally or vertically adjacent pixels" (e.g. 3)
D2 := "distance between diagonally adjacent pixels" ( e.g. 4)
MAX_DISTANCE_VALUE := (I.width+I.height)*max(D1,D2)
for all pixel (x,y) of I do
if I(x,y) == 255 then
C(x,y) = 0
else
C(x,y) = MAX_DISTANCE_VALUE
endif
endfor
w := C.width
h := C.height
for x = 1 to w-2 do
for y = 1 to h-1 do
C(x,y) = min( C(x,y), C(x-1,y)+d1 , C(x-1,y-1)+d2 , C(x,y-1)+d1 , C(x+1,y-1)+d2 )
endfor
endfor
for x = w-2 to 1 do
for y = h-2 to 0 do
C(x,y) = min( C(x,y) , C(x+1,y)+d1 , C(x+1,y+1)+d2 , C(x,y+1)+d1 , C(x-1,y+1)+d2 )
endfor
endfor
h1 := h-1;
h2 := h1-1;
w1 := w-1;
w2 := w1-1;
for y = 0 to h-1 do
C(0,y) = C(1,y);
C(w1,y) = C(w2,y) ;
endfor
for x = 0 to w-1 do
C(x,0) = C(x,1);
C(x,h1) = C(x,h2) ;
endfor
return C
Benchmarks:
The chamfering operation complexity is linear to pixel count of an image and it does not change with different input image types:
Image-size 640x480 single channel (Pentium M 1.6GHz)
- scaleFactor 1: approx. 20ms
- scaleFactor 2: approx. 5.5ms (with up-scaling 14ms)
- scaleFactor 4: approx. 2ms (with up-scaling 11ms)
- scaleFactor 8: approx. 1ms (with up-scaling 10ms)
ROI support
Currently image ROIs are supported, but the chamfering operation will perform step 4 of the above presented algorithm with the image ROI Rect if there is a ROI defined on I.
Explicit scaling
A new feature of the ChamferOp class can be activated using the "scaleFactor" argument of the class constructor. If the given scale-factor is greater then 1, the chamfering operation is applied only on an image, that is scaled down by that factor. The last constructor argument (scaleUpResult) can be used to define whether to scale up the resulting chamfer Image (using NN-Interpolation this time), or to let the result image become smaller (by the scale-factor) then the input image.
Internally the down-scaling is not actually performed, but it is emulated by iterating creating a downscaled chamfer image (Step 1 in the algorithm above). By this means, a scaleFactor of 2 (in x and y direction) provides nearly 400% of the computation speed compared to scale factor 1.
The "scaleUpResult" Feature, however slows down the performace again, as the image scaling operation is more expensive too. (
- See also
- BENCH)
Hausdorff-Distance
The Hausdorff-Distance is a metric to measure the similarity of two point sets and . It is defined by:
where
and is some underlying norm of the points of A and B (e.g. the Euclidean norm) is often called the symmetric Hausdorff-Distance and is often called the directed Hausdorff-Distance.
The implementation of the Hausdorff-Distance measurement refers to the chamfering algorithm to calculate point the "min" distances in constant time.
Hausdorff-Distance measurement functions
In addition to the Chamfering-operation provided by the ChamferOp class as an implementation of the UnaryOp interface, the class provides some static functions to calculate the Hausdorff-Distance. Point-sets can here be defined as a std::vector<Point> or directly as a chamfer'd image, which can increase calculation performance when comparing one Base- image (chamfered once) with many models.
Hausdorff-Distance ROI penalties
When comparing images using the Hausdorff-Distance, sometimes a model, represented by a point set must be compared with an image that is represented by a chamfering image . If the image has no full ROI, it is not clear what to do with model points that are inside of the image rect but outside the images ROI. To increase performance, the image is just chamfered inside of its ROI, so no correct chamfering information (nearest white pixel distances) are available outside of the images ROI. The ChamferOp class provides 3 heuristics to tackle outer-ROI outliers of the model which are defined by a so called "outerROIPenaltyMode" (implemented as enum).
- noPenalty outliers are skipped
- constPenalty outliers are punished with a constant value, that can be set manually
- distancePenalty outliers are punished proportionally to the distance to the images ROI (the distance value can be weighted linearly by a manually given factor)
Copying
Please note, that ChampferOp instances are copied shallowly. By this means, you can cheaply pass ChampferOp instances to function calls, but this ops share their internal image buffer, so in some cases inpredictable behaviour can occur.