Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
icl::filter::CannyOp Class Reference

Class for the canny edge detector. More...

#include <CannyOp.h>

Inheritance diagram for icl::filter::CannyOp:
icl::filter::UnaryOp icl::utils::Uncopyable icl::utils::Configurable

Public Member Functions

 CannyOp (icl32f lowThresh=0, icl32f highThresh=255, int preBlurRadius=0)
 Constructor. More...
 
 CannyOp (UnaryOp *dxOp, UnaryOp *dyOp, icl32f lowThresh=0, icl32f highThresh=255, bool deleteOps=true, int preBlurRadius=0)
 Constructor. More...
 
virtual ~CannyOp ()
 Destructor. More...
 
void setThresholds (icl32f lowThresh, icl32f highThresh)
 changes the Thresholds More...
 
icl32f getLowThreshold () const
 returns the lower threshold More...
 
icl32f getHighThreshold () const
 returns the upper threshold More...
 
virtual void apply (const core::ImgBase *src, core::ImgBase **dst)
 applies the Canny Operator More...
 
virtual void apply (const core::ImgBase *src_x, const core::ImgBase *src_y, core::ImgBase **dst)
 applies the Canny Operator More...
 
void setPreBlurRadius (int preBlurRadius)
 sets the pre-blur-radius More...
 
void setUseDerivativesInfo (bool use_derivatives)
 
bool getPreBlurRadius () const
 returns current pre-blur feature state More...
 
- Public Member Functions inherited from icl::filter::UnaryOp
 UnaryOp ()
 Explicit empty constructor. More...
 
 UnaryOp (const UnaryOp &other)
 Explicit copy constructor. More...
 
UnaryOpoperator= (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::ImgBaseapply (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::ImgBaseoperator() (const core::ImgBase *src)
 function operator for the implicit destination apply(src) call More...
 
const core::ImgBaseoperator() (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) throw (utils::ICLException)
 sets value of a property (always call call_callbacks(propertyName) or Configurable::setPropertyValue) More...
 
- Public Member Functions inherited from icl::utils::Configurable
virtual ~Configurable ()
 virtual destructor More...
 
 Configurable (const Configurable &other)
 Copy constructor. More...
 
Configurableoperator= (const Configurable &other)
 Assignment operator. More...
 
void setConfigurableID (const std::string &ID) throw (ICLException)
 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) throw (ICLException)
 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...
 

Private Member Functions

void property_callback (const Property &p)
 
void setUpPreBlurOp ()
 
void applyCanny32f (const core::ImgBase *dx, const core::ImgBase *dy, core::ImgBase *dst, int c)
 applies canny for one channel More...
 
void applyCanny16s (const core::ImgBase *dx, const core::ImgBase *dy, core::ImgBase *dst, int c)
 

Private Attributes

std::vector< icl8um_cannyBuf
 buffer for ippiCanny More...
 
core::ImgBasem_derivatives [2]
 
UnaryOpm_ops [2]
 
UnaryOpm_preBlurOp
 
icl32f m_lowT
 
icl32f m_highT
 
bool m_ownOps
 
bool m_use_derivatives_info
 
core::Img32f m_buffer
 
int m_preBlurRadius
 

Additional Inherited Members

- Public Types inherited from icl::utils::Configurable
typedef Function< void, const
Property & > 
Callback
 Function type for changed properties. More...
 
- Static Public Member Functions inherited from icl::filter::UnaryOp
static UnaryOpfromString (const std::string &definition) throw (utils::ICLException)
 Creates a UnaryOp instance from given string definition. More...
 
static std::string getFromStringSyntax (const std::string &opSpecifier) throw (utils::ICLException)
 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) throw (utils::ICLException)
 creates, applies and releases a UnaryOp defined by given definition string More...
 
- Static Public Member Functions inherited from icl::utils::Configurable
static std::string create_default_ID (const std::string &prefix)
 this function can be used in subclasses to create a default ID More...
 
static Configurableget (const std::string &id)
 returns configurable by given ID More...
 
static void register_configurable_type (const std::string &classname, Function< Configurable * > creator) throw (ICLException)
 registers a configurable type More...
 
static std::vector< std::string > get_registered_configurables ()
 returns a list of all registered configurable classnames More...
 
static Configurablecreate_configurable (const std::string &classname) throw (ICLException)
 creates a configurable by given name More...
 
- Static Public Attributes inherited from icl::utils::Configurable
static const std::vector
< std::string > 
EMPTY_VEC
 used as shortcut – just an empty vector of std::strings More...
 
- Protected Member Functions inherited from icl::filter::UnaryOp
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)
 
- Protected Member Functions inherited from icl::utils::Configurable
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()) throw (ICLException)
 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...
 
Propertyprop (const std::string &propertyName) throw (ICLException)
 this CAN be used e.g. to store a property value in internal property-list More...
 
const Propertyprop (const std::string &propertyName) const throw (ICLException)
 this CAN be used e.g. to store a property value in internal property-list More...
 
 Configurable (const std::string &ID="", bool ordered=true) throw (ICLException)
 create this configurable with given ID More...
 
void call_callbacks (const std::string &propertyName, const Configurable *caller) const
 calls all registered callbacks More...
 
- Protected Member Functions inherited from icl::utils::Uncopyable
 Uncopyable ()
 Empty base constructor. More...
 
- Protected Attributes inherited from icl::filter::UnaryOp
utils::MultiThreaderm_poMT
 
- Protected Attributes inherited from icl::utils::Configurable
std::vector< Callbackcallbacks
 internally managed list of callbacks More...
 

Detailed Description

Class for the canny edge detector.

Overview

The canny edge detector detects image borders from gray-scale images. It's result is an Img8u binary image containing thin borders.

Algorithm

The canny edge detector is a very common filter for edge detection, therefore it is already implemented in the IPP. The algorithm can be split into 3 major parts:

  1. Image differentiation here, image x and y gradients are computed. Commonly this is done using sobel- X and -Y filters.
  2. Non-Maximum suppression The image differentiation result is converted into an image intensity map and into a gradient direction map. Now all pixels are suppressed, that are not ridges in gradient intensity map mountain.
  3. Thresholding Here a special threshold operation is used. Two threshold values (l=low threshold and h=high threshold) split the edge intensity scale into 3 parts:
    1. below the lower threshold pixels with such values are in any case no border pixels
    2. above the upper threshold these pixels are border pixels
    3. in the middle section these pixels are only border pixels if there's a connected chain of other pixels (each also in the middle section) that is connected in any way to a border pixel.

(please see IPP's canny edge detector documentation for more detail)

pre-blur features

In some cases (e.g. if input images are created synthetically) the border intensity image has too hard edges (e.g. from edges from black to white). In this case, the canny edge detector implementation overlooks these borders independent on the given threshold values.

Constructor & Destructor Documentation

icl::filter::CannyOp::CannyOp ( icl32f  lowThresh = 0,
icl32f  highThresh = 255,
int  preBlurRadius = 0 
)

Constructor.

With this Constructor the derivations are computed within the CannyOp. If you already have computed the derivations, use the other Constructor, due to performance reasons.

Parameters
lowThreshlower threshold
highThreshupper threshold
preBlurRadiusif r> 0, gaussian kernel with masksize r*2+1 is applied to the input image first
icl::filter::CannyOp::CannyOp ( UnaryOp dxOp,
UnaryOp dyOp,
icl32f  lowThresh = 0,
icl32f  highThresh = 255,
bool  deleteOps = true,
int  preBlurRadius = 0 
)

Constructor.

Parameters
dxOpthe x derivation of the src
dyOpthe y derivation of the src
lowThreshlower threshold
highThreshupper threshold
deleteOpsshould the internaly created derivations be deleted?
preBlurRadiusif r> 0, gaussian kernel with masksize r*2+1 is applied to the input image first
virtual icl::filter::CannyOp::~CannyOp ( )
virtual

Destructor.

Member Function Documentation

virtual void icl::filter::CannyOp::apply ( const core::ImgBase src,
core::ImgBase **  dst 
)
virtual

applies the Canny Operator

Parameters
srcthe source image
dstpointer to the destination image

Implements icl::filter::UnaryOp.

virtual void icl::filter::CannyOp::apply ( const core::ImgBase src_x,
const core::ImgBase src_y,
core::ImgBase **  dst 
)
virtual

applies the Canny Operator

Parameters
srcthe source image
dstpointer to the destination image
void icl::filter::CannyOp::applyCanny16s ( const core::ImgBase dx,
const core::ImgBase dy,
core::ImgBase dst,
int  c 
)
private
void icl::filter::CannyOp::applyCanny32f ( const core::ImgBase dx,
const core::ImgBase dy,
core::ImgBase dst,
int  c 
)
private

applies canny for one channel

icl32f icl::filter::CannyOp::getHighThreshold ( ) const

returns the upper threshold

Returns
the upper threshold
icl32f icl::filter::CannyOp::getLowThreshold ( ) const

returns the lower threshold

Returns
the lower threshold
bool icl::filter::CannyOp::getPreBlurRadius ( ) const
inline

returns current pre-blur feature state

void icl::filter::CannyOp::property_callback ( const Property p)
private
void icl::filter::CannyOp::setPreBlurRadius ( int  preBlurRadius)
inline

sets the pre-blur-radius

if r> 0, gaussian kernel with masksize r*2+1 is applied to the input image first

void icl::filter::CannyOp::setThresholds ( icl32f  lowThresh,
icl32f  highThresh 
)

changes the Thresholds

Parameters
lowThreshlower threshold
highThreshupper threshold
void icl::filter::CannyOp::setUpPreBlurOp ( )
private
void icl::filter::CannyOp::setUseDerivativesInfo ( bool  use_derivatives)
inline

Member Data Documentation

core::Img32f icl::filter::CannyOp::m_buffer
private
std::vector<icl8u> icl::filter::CannyOp::m_cannyBuf
private

buffer for ippiCanny

core::ImgBase* icl::filter::CannyOp::m_derivatives[2]
private
icl32f icl::filter::CannyOp::m_highT
private
icl32f icl::filter::CannyOp::m_lowT
private
UnaryOp* icl::filter::CannyOp::m_ops[2]
private
bool icl::filter::CannyOp::m_ownOps
private
UnaryOp* icl::filter::CannyOp::m_preBlurOp
private
int icl::filter::CannyOp::m_preBlurRadius
private
bool icl::filter::CannyOp::m_use_derivatives_info
private

The documentation for this class was generated from the following file: