IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Detects surfaces in a 3d image using Canny's algorithm. More...

IPSDKIPLFEATUREDETECTION_API image::ImagePtr ipsdk::imaproc::fd::cannySurfaces3dImg (const image::ImageConstPtr &pInGxImg3d, const image::ImageConstPtr &pInGyImg3d, const image::ImageConstPtr &pInGzImg3d, const ipsdk::imaproc::attr::CannyThresholdsConstPtr &pThresholds)
 wrapper function for detection of edges in images using Canny's algorithm More...
 
IPSDKIPLFEATUREDETECTION_API void ipsdk::imaproc::fd::cannySurfaces3dImg (const image::ImageConstPtr &pInGxImg3d, const image::ImageConstPtr &pInGyImg3d, const image::ImageConstPtr &pInGzImg3d, const ipsdk::imaproc::attr::CannyThresholdsConstPtr &pThresholds, const ipsdk::imaproc::attr::eProcessingOptimizationPolicy &inOptOptimizationPolicy, const image::ImagePtr &pOutImg)
 wrapper function for detection of edges in images using Canny's algorithm More...
 

Detailed Description

Detects surfaces in a 3d image using Canny's algorithm.

Detects boundary surfaces in a 3d image using Canny's algorithm, and generates an output binary image, with voxels associated to the found surfaces in white, and the rest in black.

Given 3 gradient images (computed, for instance, thanks to Sobel Gradient 3d or Gaussian Gradient 3d), respectively along x (Gx image), y (Gy image) and z-axis (Gz image), Canny surface detector can be decomposed into the following steps:

  1. from Gx, Gy and Gz images, magnitude and orientation of gradient is computed
  2. non-maxima suppression: for each voxel in the image of gradient magnitude, if the pixel value is greater than the values of its 2 neighbours along the gradient direction, then the pixel is marked as "to be processed"; otherwise, it is marked as "not a boundary surface". This step prevents from having too thick boundary surfaces.
  3. for all voxels tagged "to be processed", mark as:
    • "not a boundary surface" voxels whose gradient magnitude value is lower than low threshold value specified by the user
    • "strong boundary surface" voxels whose gradient magnitude value is higher than high threshold value specified by the user
    • "perhaps a boundary surface" voxels whose gradient magnitude value is between low and high threshold values
  4. process voxels tagged "perhaps a boundary surface": a voxel tagged "perhaps a boundary surface" is a strong boundary surface if it is directly or indirectly (ie. there exists a path of connected voxels tagged "perhaps a boundary surface" that link the current voxel to a "strong boundary surface" voxel) connected to a "strong boundary surface" voxel. Otherwise it is affected the "not a boundary surface" value.

See 2d Canny edge detector for an illustration of Canny edge detection applied to a 2d image.

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InGxGreyImg3d [Input] 3d grey levels image of gradient computed along x-axis X
ipsdk::imaproc::attr::InGyGreyImg3d [Input] 3d grey levels image of gradient computed along y-axis X
ipsdk::imaproc::attr::InGzGreyImg3d [Input] 3d grey levels image of gradient computed along z-axis X
ipsdk::imaproc::attr::InCannyThresholds [Input] low and high thresholds used for the Canny edges detection during the hysteresis phasis X
ipsdk::imaproc::attr::InOptOptimizationPolicy [Input Optional] processing optimization policy for algorithm X
ipsdk::imaproc::attr::OutOptWk1BinImg [Output Optional] Temporary working image for algorithm X
ipsdk::imaproc::attr::OutOptWk2BinImg [Output Optional] Temporary working image for algorithm X
ipsdk::imaproc::attr::OutOptWk1LabelImg [Output Optional] Temporary working image for algorithm X
ipsdk::imaproc::attr::OutBinImg [Output] binary image for processing operation ipsdk::imaproc::duplicateInOut (_pOutBinImg, _pInGxGreyImg3d, ipsdk::image::eImageBufferType::eIBT_Binary)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSize (_pInGxGreyImg3d,_pInGyGreyImg3d) && 
ipsdk::imaproc::matchSize (_pInGxGreyImg3d,_pInGzGreyImg3d) && 
ipsdk::imaproc::matchSize (_pInGxGreyImg3d,_pOutBinImg) && 
(ipsdk::processor::ifIsSet (
  _pOutOptWk1BinImg, (
   ipsdk::imaproc::matchSize (_pInGxGreyImg3d,_pOutOptWk1BinImg)))) && 
(ipsdk::processor::ifIsSet (
  _pOutOptWk2BinImg, (
   ipsdk::imaproc::matchSize (_pInGxGreyImg3d,_pOutOptWk2BinImg)))) && 
(ipsdk::processor::ifIsSet (
  _pOutOptWk1LabelImg, (
   ipsdk::imaproc::matchSize (_pInGxGreyImg3d,_pOutOptWk1LabelImg))))

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLFeatureDetection as fd
import PyIPSDK.IPSDKIPLFiltering as filter

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
inImg = filter.gaussianSmoothing3dImg(inImg, 1.0);
# associated gradient images computation
gxImg, gyImg, gzImg = filter.sobelGradient3dImg(inImg, PyIPSDK.eSobelKernelType.eSKT_SobelHalfKnlSz1, True)
outImg = fd.cannySurfaces3dImg(gxImg, gyImg, gzImg, PyIPSDK.createCannyThresholds(50, 100))

Example of C++ code :

Example informations

Associated library

IPSDKIPLFeatureDetection

Header file

Code Example

ImageConstPtr pInImg = loadTiffImageFile(inImgPath);
ImageGeometryPtr pGradGeometry = geometry3d(eImageBufferType::eIBT_Real32, pInImg->getSizeX(), pInImg->getSizeY(), pInImg->getSizeZ());
boost::shared_ptr<MemoryImage> pGxImg = boost::make_shared<MemoryImage>();
pGxImg->init(*pGradGeometry);
boost::shared_ptr<MemoryImage> pGyImg = boost::make_shared<MemoryImage>();
pGyImg->init(*pGradGeometry);
boost::shared_ptr<MemoryImage> pGzImg = boost::make_shared<MemoryImage>();
pGzImg->init(*pGradGeometry);
ImageGeometryPtr pOutGeometry = geometry3d(eImageBufferType::eIBT_Binary, pInImg->getSizeX(), pInImg->getSizeY(), pInImg->getSizeZ());
boost::shared_ptr<MemoryImage> pOutImg = boost::make_shared<MemoryImage>();
pOutImg->init(*pOutGeometry);
filter::sobelGradient3dImg(pInImg, eSobelKernelType::eSKT_SobelHalfKnlSz1, false, pGxImg, pGyImg, pGzImg);
cannySurfaces3dImg(pGxImg, pGyImg, pGzImg, pThresholds, eProcessingOptimizationPolicy::ePOP_MaximizeSpeed, pOutImg);
See also
CannySurfaces3dImgLvl1
CannySurfaces3dImgLvl2
CannySurfaces3dImgLvl3

Function Documentation

◆ cannySurfaces3dImg() [1/2]

IPSDKIPLFEATUREDETECTION_API image::ImagePtr ipsdk::imaproc::fd::cannySurfaces3dImg ( const image::ImageConstPtr pInGxImg3d,
const image::ImageConstPtr pInGyImg3d,
const image::ImageConstPtr pInGzImg3d,
const ipsdk::imaproc::attr::CannyThresholdsConstPtr pThresholds 
)

wrapper function for detection of edges in images using Canny's algorithm

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ cannySurfaces3dImg() [2/2]

IPSDKIPLFEATUREDETECTION_API void ipsdk::imaproc::fd::cannySurfaces3dImg ( const image::ImageConstPtr pInGxImg3d,
const image::ImageConstPtr pInGyImg3d,
const image::ImageConstPtr pInGzImg3d,
const ipsdk::imaproc::attr::CannyThresholdsConstPtr pThresholds,
const ipsdk::imaproc::attr::eProcessingOptimizationPolicy inOptOptimizationPolicy,
const image::ImagePtr pOutImg 
)

wrapper function for detection of edges in images using Canny's algorithm

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure