Image Component Library (ICL)
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...
 
virtual void apply (const core::ImgBase *operand1, core::ImgBase **dst)=0
 Import unaryOps apply function without destination image. More...
 
virtual const core::ImgBaseapply (const core::ImgBase *src)
 Import unaryOps apply function without destination image. 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)
 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)
 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...
 

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)
 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 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)
 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)
 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())
 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)
 this CAN be used e.g. to store a property value in internal property-list More...
 
const Propertyprop (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...
 
- 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

◆ CannyOp() [1/2]

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

◆ CannyOp() [2/2]

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

◆ ~CannyOp()

virtual icl::filter::CannyOp::~CannyOp ( )
virtual

Destructor.

Member Function Documentation

◆ apply() [1/4]

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.

◆ apply() [2/4]

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

◆ apply() [3/4]

virtual void icl::filter::UnaryOp::apply

Import unaryOps apply function without destination image.

◆ apply() [4/4]

virtual const core::ImgBase* icl::filter::UnaryOp::apply

Import unaryOps apply function without destination image.

◆ applyCanny16s()

void icl::filter::CannyOp::applyCanny16s ( const core::ImgBase dx,
const core::ImgBase dy,
core::ImgBase dst,
int  c 
)
private

◆ applyCanny32f()

void icl::filter::CannyOp::applyCanny32f ( const core::ImgBase dx,
const core::ImgBase dy,
core::ImgBase dst,
int  c 
)
private

applies canny for one channel

◆ getHighThreshold()

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

returns the upper threshold

Returns
the upper threshold

◆ getLowThreshold()

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

returns the lower threshold

Returns
the lower threshold

◆ getPreBlurRadius()

bool icl::filter::CannyOp::getPreBlurRadius ( ) const
inline

returns current pre-blur feature state

◆ property_callback()

void icl::filter::CannyOp::property_callback ( const Property p)
private

◆ setPreBlurRadius()

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

◆ setThresholds()

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

changes the Thresholds

Parameters
lowThreshlower threshold
highThreshupper threshold

◆ setUpPreBlurOp()

void icl::filter::CannyOp::setUpPreBlurOp ( )
private

◆ setUseDerivativesInfo()

void icl::filter::CannyOp::setUseDerivativesInfo ( bool  use_derivatives)
inline

Member Data Documentation

◆ m_buffer

core::Img32f icl::filter::CannyOp::m_buffer
private

◆ m_cannyBuf

std::vector<icl8u> icl::filter::CannyOp::m_cannyBuf
private

buffer for ippiCanny

◆ m_derivatives

core::ImgBase* icl::filter::CannyOp::m_derivatives[2]
private

◆ m_highT

icl32f icl::filter::CannyOp::m_highT
private

◆ m_lowT

icl32f icl::filter::CannyOp::m_lowT
private

◆ m_ops

UnaryOp* icl::filter::CannyOp::m_ops[2]
private

◆ m_ownOps

bool icl::filter::CannyOp::m_ownOps
private

◆ m_preBlurOp

UnaryOp* icl::filter::CannyOp::m_preBlurOp
private

◆ m_preBlurRadius

int icl::filter::CannyOp::m_preBlurRadius
private

◆ m_use_derivatives_info

bool icl::filter::CannyOp::m_use_derivatives_info
private

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