IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Compute X and Y gradients of an input image convolving it with 2d Sobel kernels. More...

IPSDKIPLFILTERING_API GradientXYImg ipsdk::imaproc::filter::sobelGradient2dImg (const image::ImageConstPtr &pInImg)
 wrapper function for Sobel filter used to compute gradient on a 2d image More...
 
IPSDKIPLFILTERING_API GradientXYImg ipsdk::imaproc::filter::sobelGradient2dImg (const image::ImageConstPtr &pInImg, const ipsdk::eSobelKernelType &kernelType, const bool bNormalize)
 wrapper function for Sobel filter used to compute gradient on a 2d image More...
 
IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::sobelGradient2dImg (const image::ImageConstPtr &pInImg, const ipsdk::eSobelKernelType &kernelType, const bool bNormalize, const image::ImagePtr &pOutOptGradXImg, const image::ImagePtr &pOutOptGradYImg)
 wrapper function for Sobel filter used to compute gradient on a 2d image More...
 
IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::sobelXGradient2dImg (const image::ImageConstPtr &pInImg)
 wrapper function for Sobel filter used to compute gradient on a 2d image More...
 
IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::sobelXGradient2dImg (const image::ImageConstPtr &pInImg, const ipsdk::eSobelKernelType &kernelType, const bool bNormalize)
 wrapper function for Sobel filter used to compute gradient on a 2d image More...
 
IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::sobelXGradient2dImg (const image::ImageConstPtr &pInImg, const ipsdk::eSobelKernelType &kernelType, const bool bNormalize, const image::ImagePtr &pOutXGradImg)
 wrapper function for Sobel filter used to compute gradient on a 2d image More...
 
IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::sobelYGradient2dImg (const image::ImageConstPtr &pInImg)
 wrapper function for Sobel filter used to compute gradient on a 2d image More...
 
IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::sobelYGradient2dImg (const image::ImageConstPtr &pInImg, const ipsdk::eSobelKernelType &kernelType, const bool bNormalize)
 wrapper function for Sobel filter used to compute gradient on a 2d image More...
 
IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::sobelYGradient2dImg (const image::ImageConstPtr &pInImg, const ipsdk::eSobelKernelType &kernelType, const bool bNormalize, const image::ImagePtr &pOutYGradImg)
 wrapper function for Sobel filter used to compute gradient on a 2d image More...
 

Detailed Description

Compute X and Y gradients of an input image convolving it with 2d Sobel kernels.

2d Sobel kernels are separable, they can be decomposed as the product of a row vector and a column vector. X gradient kernel equals to the product of the smoothing (column) vector with the derivative (row) vector, while Y gradient kernel equals to the product of the derivative (column) vector with the smoothing (row) vector. Depending on the value of parameter $InOptSobelKernelType$ (default value: eSKT_SobelHalfKnlSz1), smoothing and derivative vectors equal to:

To handle image borders, a mirror extrapolation is used (see Border policy for more details).

Here is an example of a Sobel gradient applied to an 8-bits grey levels input image with default parameters used:

sobelGradient2d.png
See also
https://en.wikipedia.org/wiki/Sobel_operator

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InOptSobelKernelType [Input Optional] kernel type for Sobel gradient filter X
ipsdk::imaproc::attr::InOptNormalizeSobelKernel [Input Optional] boolean flag indicating whether kernel use for Sobel gradient filtering has to be normalized or not X
ipsdk::imaproc::attr::OutOptGradXImg [Output Optional] image associated to X component of gradient computation promoteUnary (_pOutOptGradXImg, _pInImg, ipsdk::imaproc::ePromoteUnaryType::ePUT_UpperSigned)
ipsdk::imaproc::attr::OutOptGradYImg [Output Optional] image associated to Y component of gradient computation promoteUnary (_pOutOptGradYImg, _pInImg, ipsdk::imaproc::ePromoteUnaryType::ePUT_UpperSigned)

Global Rule description

Global rule description for algorithm :
((ipsdk::processor::isSet (_pOutOptGradXImg) || 
  ipsdk::processor::isSet (_pOutOptGradYImg)) && 
 (ipsdk::processor::ifIsSet (_pOutOptGradXImg,
   ipsdk::imaproc::matchSize (_pInImg,_pOutOptGradXImg))) && 
 (ipsdk::processor::ifIsSet (_pOutOptGradYImg,
   ipsdk::imaproc::matchSize (_pInImg,_pOutOptGradYImg))))

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLFiltering as filter

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# Sobel gradient filter 2d computation
outGxImg, outGyImg = filter.sobelGradient2dImg(inImg)

Example of C++ code :

Example informations

Associated library

IPSDKIPLFiltering

Header file

Code Example

// opening input image from TIFF file
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
// applying Sobel gradient to input image
GradientXYImg gradientXY = sobelGradient2dImg(pInImg);
See also
SobelGradient2dImgLvl1

Function Documentation

◆ sobelGradient2dImg() [1/3]

IPSDKIPLFILTERING_API GradientXYImg ipsdk::imaproc::filter::sobelGradient2dImg ( const image::ImageConstPtr pInImg)

wrapper function for Sobel filter used to compute gradient on a 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ sobelGradient2dImg() [2/3]

IPSDKIPLFILTERING_API GradientXYImg ipsdk::imaproc::filter::sobelGradient2dImg ( const image::ImageConstPtr pInImg,
const ipsdk::eSobelKernelType kernelType,
const bool  bNormalize 
)

wrapper function for Sobel filter used to compute gradient on a 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ sobelGradient2dImg() [3/3]

IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::sobelGradient2dImg ( const image::ImageConstPtr pInImg,
const ipsdk::eSobelKernelType kernelType,
const bool  bNormalize,
const image::ImagePtr pOutOptGradXImg,
const image::ImagePtr pOutOptGradYImg 
)

wrapper function for Sobel filter used to compute gradient on a 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ sobelXGradient2dImg() [1/3]

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::sobelXGradient2dImg ( const image::ImageConstPtr pInImg)

wrapper function for Sobel filter used to compute gradient on a 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ sobelXGradient2dImg() [2/3]

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::sobelXGradient2dImg ( const image::ImageConstPtr pInImg,
const ipsdk::eSobelKernelType kernelType,
const bool  bNormalize 
)

wrapper function for Sobel filter used to compute gradient on a 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ sobelXGradient2dImg() [3/3]

IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::sobelXGradient2dImg ( const image::ImageConstPtr pInImg,
const ipsdk::eSobelKernelType kernelType,
const bool  bNormalize,
const image::ImagePtr pOutXGradImg 
)

wrapper function for Sobel filter used to compute gradient on a 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ sobelYGradient2dImg() [1/3]

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::sobelYGradient2dImg ( const image::ImageConstPtr pInImg)

wrapper function for Sobel filter used to compute gradient on a 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ sobelYGradient2dImg() [2/3]

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::sobelYGradient2dImg ( const image::ImageConstPtr pInImg,
const ipsdk::eSobelKernelType kernelType,
const bool  bNormalize 
)

wrapper function for Sobel filter used to compute gradient on a 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ sobelYGradient2dImg() [3/3]

IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::sobelYGradient2dImg ( const image::ImageConstPtr pInImg,
const ipsdk::eSobelKernelType kernelType,
const bool  bNormalize,
const image::ImagePtr pOutYGradImg 
)

wrapper function for Sobel filter used to compute gradient on a 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure