IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Apply hysteresis thresholding to an image. More...

IPSDKIPLBINARIZATION_API ipsdk::image::ImagePtr ipsdk::imaproc::bin::darkHysteresisThreshold2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::ipReal64 highSeedThreshold, const ipsdk::ipReal64 highPropagationThreshold)
 wrapper function for dark Hysteresis thresholding to an image More...
 
IPSDKIPLBINARIZATION_API ipsdk::image::ImagePtr ipsdk::imaproc::bin::lightHysteresisThreshold2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::ipReal64 lowSeedThreshold, const ipsdk::ipReal64 lowPropagationThreshold)
 wrapper function for light Hysteresis thresholding to an image More...
 
IPSDKIPLBINARIZATION_API ipsdk::image::ImagePtr ipsdk::imaproc::bin::hysteresisThreshold2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::ipReal64 lowSeedThreshold, const ipsdk::ipReal64 highSeedThreshold, const ipsdk::ipReal64 lowPropagationThreshold, const ipsdk::ipReal64 highPropagationThreshold)
 wrapper function for Apply hysteresis thresholding to an image More...
 
IPSDKIPLBINARIZATION_API void ipsdk::imaproc::bin::hysteresisThreshold2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::ipReal64 lowSeedThreshold, const ipsdk::ipReal64 highSeedThreshold, const ipsdk::ipReal64 lowPropagationThreshold, const ipsdk::ipReal64 highPropagationThreshold, const ipsdk::eNeighborhood2dType &inOptNeighborhood2d, const image::ImagePtr &pOutBinImg)
 wrapper function for Apply hysteresis thresholding to an image More...
 

Detailed Description

Apply hysteresis thresholding to an image.

Hysteresis threshold algorithm applies two thresholds $T_S$ and $T_P$ on the output image. $T_S$ is the most restrictive threshold and yields a seed image $I_S$, used to propagate the marked features in $I_P$, obtained by thresholding the input image by $T_P$. This algorithm is commonly used in edge detection such as Canny edge detector.

The aim of this threshold is to preserve the features in $I_P$ containing a seed in $I_S$.

The algorithm needs 4 thresholds: the minimum and maximum thresholds $T_S^{Min}$ and $T_S^{Max}$ to compute the seed image $I_S$ and the minimum and maximum thresholds $T_P^{Min}$ and $T_P^{Max}$ to compute the image $I_P$, used for the propagation.

\begin{eqnarray*} I_S[i] & = & \begin{cases} 1, & \text{if } T_S^{Min} \leq InImg[i] \leq T_S^{Max} \\ 0, & \text{otherwise} \end{cases} \\ I_P[i] & = & \begin{cases} 1, & \text{if } T_P^{Min} \leq InImg[i] \leq T_P^{Max} \\ 0, & \text{otherwise} \end{cases} \end{eqnarray*}

To simplify the algorithm parametrization, several wrappers are defined to apply this threshold:

Here is an example of dark and light hysteresis threshold applied to a gray scale input image. The intensities of each area are indicated we used $T_S^{Max} = 4 $ and $T_P^{Max} = 32 $ for the dark threshold and $T_S^{Min} = 100 $ and $T_P^{Min} = 64 $ fot the light threshold:

hysteresisThreshold2dImg.png

The features and seeds intensities may be higher than the minimum image intensity and lower than the maximum image intensity. The hysteresisThreshold2dImg wrapper allows to handle this case, illustrated by the following figure. In this example, the background have an intensity of 50, the two little white circles have an intensity of 255, the intensity of the central main ellipse equals 96 and the two lighter ellipses inside have an intensity of 192 (left) and 128 (right). Finally, the intensity of the contour of the main ellipse varies from 12 to 44. The threshold used for the calculation are: $T_S^{Min} = 100$, $T_P^{Min} = 60$ and $T_S^{Max} = T_P^{Max} = 200$.

hysteresisThreshold2dImg_generic.png

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InHysteresisParams [Input] Parameters for hysteresis threshold X
ipsdk::imaproc::attr::InOptNeighborhood2d [Input optional] neighborhood 2d type for operation X
ipsdk::imaproc::attr::OutOptWk1BinImg [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, _pInImg, image::eImageBufferType::eIBT_Binary)

Global Rule description

Global rule description for algorithm :
(ipsdk::imaproc::matchSize (_pInImg,_pOutBinImg) && 
 (ipsdk::processor::ifIsSet (
   _pOutOptWk1LabelImg, (
    ipsdk::imaproc::matchSize (_pInImg,_pOutOptWk1LabelImg)))) && 
 (ipsdk::processor::ifIsSet (
   _pOutOptWk1LabelImg, (
    ipsdk::imaproc::matchSize (_pInImg,_pOutOptWk1LabelImg)))))

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLBinarization as bin

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# threshold computation
outImg = bin.hysteresisThreshold2dImg(inImg, 100, 127, 64, 127)

Example of C++ code :

Example informations

Associated library

IPSDKIPLBinarization

Header file

Code Example

// Compute the dark hysteresis threshold
// --------------------------------------
ImagePtr pOutImg_dark = darkHysteresisThreshold2dImg(pInImg, threshSeedMax_dark, threshPropagationMax_dark);
// Compute the light hysteresis threshold
// --------------------------------------
ImagePtr pOutImg_light = lightHysteresisThreshold2dImg(pInImg, threshSeedMin_light, threshPropagationMin_light);
// Compute the hysteresis threshold with
// custom params and provided ouput image
// --------------------------------------
const ipUInt64 sizeX = pInImg->getSizeX();
const ipUInt64 sizeY = pInImg->getSizeY();
// Create output image
ImageGeometryPtr pOutputImageGeometry = geometry2d(eImageBufferType::eIBT_Binary, sizeX, sizeY);
boost::shared_ptr<MemoryImage> pOutImg(boost::make_shared<MemoryImage>());
pOutImg->init(*pOutputImageGeometry);
// Compute the threshold
hysteresisThreshold2dImg(pInImg, threshSeedMin, threshSeedMax, threshPropagationMin, threshPropagationMax, neighbourhood2d, pOutImg);
See also
HysteresisThreshold2dImgLvl1

Function Documentation

◆ darkHysteresisThreshold2dImg()

IPSDKIPLBINARIZATION_API ipsdk::image::ImagePtr ipsdk::imaproc::bin::darkHysteresisThreshold2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::ipReal64  highSeedThreshold,
const ipsdk::ipReal64  highPropagationThreshold 
)

wrapper function for dark Hysteresis thresholding to an image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ lightHysteresisThreshold2dImg()

IPSDKIPLBINARIZATION_API ipsdk::image::ImagePtr ipsdk::imaproc::bin::lightHysteresisThreshold2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::ipReal64  lowSeedThreshold,
const ipsdk::ipReal64  lowPropagationThreshold 
)

wrapper function for light Hysteresis thresholding to an image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ hysteresisThreshold2dImg() [1/2]

IPSDKIPLBINARIZATION_API ipsdk::image::ImagePtr ipsdk::imaproc::bin::hysteresisThreshold2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::ipReal64  lowSeedThreshold,
const ipsdk::ipReal64  highSeedThreshold,
const ipsdk::ipReal64  lowPropagationThreshold,
const ipsdk::ipReal64  highPropagationThreshold 
)

wrapper function for Apply hysteresis thresholding to an image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ hysteresisThreshold2dImg() [2/2]

IPSDKIPLBINARIZATION_API void ipsdk::imaproc::bin::hysteresisThreshold2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::ipReal64  lowSeedThreshold,
const ipsdk::ipReal64  highSeedThreshold,
const ipsdk::ipReal64  lowPropagationThreshold,
const ipsdk::ipReal64  highPropagationThreshold,
const ipsdk::eNeighborhood2dType inOptNeighborhood2d,
const image::ImagePtr pOutBinImg 
)

wrapper function for Apply hysteresis thresholding to an image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure