IPSDK 4.1.0.2
IPSDK : Image Processing Software Development Kit
TopHat 2d
imagedarkTopHat2dImg (inImg,inSEXY,inTopHatThreshold)
imagedarkTopHat2dImg (inImg,inSEXY,inTopHatThreshold,inOptBorderExtensionPolicy)
imagelightTopHat2dImg (inImg,inSEXY,inTopHatThreshold)
imagelightTopHat2dImg (inImg,inSEXY,inTopHatThreshold,inOptBorderExtensionPolicy)

Detailed Description

TopHat binary threshold on one 2d image.

Top-Hat transform is an operation which allows to extract small details from an image. This transformation is in this case associated to a thresholding operation to obtain a binary image. This algorithm can be customized to search for dark (black, which is the default) or light (white) small particules.

Top-Hat transformation, given a structuring element $ InSEXY $, is associated to following formula :

Where $ \odot $ and $ \circledcirc $ are respectively a closing and an opening operation (see Opening 2d and Closing 2d).

Note
Behavior of this algorithm is specialized using specific morphological structuring elements (see 2d structuring elements for more informations about these shapes).
Please refer to Usage for examples of usage of different types of specific structuring elements during morphological operations.

Here is an example of a top-hat transform 2d operation applied to a gray scale input image with a circular structuring element with radius 20 :

tophat2dImg.png
See also
http://en.wikipedia.org/wiki/Top-hat_transform
Note
This algorithm is associated with three temporary working images ipsdk::imaproc::attr::OutOptWk1Img, ipsdk::imaproc::attr::OutOptWk2Img and ipsdk::imaproc::attr::OutWk1Img.
  • ipsdk::imaproc::attr::OutOptWk1Img will only be used if InOptBorderExtensionPolicy is set to ipsdk::imaproc::attr::eBorderExtensionPolicy::eBEP_Enable. This working temporary image can be provided by user or will be automatically allocated when requested.
  • The second one (ipsdk::imaproc::attr::OutOptWk2Img) is only used in special processing cases defined via ipsdk::imaproc::morpho::eSEProcessingCase enumerate. Such situation can be tested using ipsdk::imaproc::morpho::getSEProcessingCase function and associated image buffer type can be retrieved using ipsdk::imaproc::morpho::getSEWkImageBufferType. This working temporary image can be provided by user or will be automatically allocated when requested.
  • The third one (ipsdk::imaproc::attr::OutWk1Img) is systematically needed for internal processing. This working temporary image can be provided by user or will be automatically allocated.

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLBinarization as bin

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# creation of used structuring element
structuringElement = PyIPSDK.circularSEXYInfo(15);
# dark top hat 2d image computation
outImg = bin.darkTopHat2dImg(inImg, structuringElement, 20)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLBinarization/Processor/TopHat2dImg/TopHat2dImg.h>

Code Example

// create a 6x2 rectangular structuring element
// opening input image
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
// compute dark tophat on input image
ImagePtr pOutImgDark = darkTopHat2dImg(pInImg, pInSEXY, 30);