image = | darkTopHat2dImg (inImg,inSEXY,inTopHatThreshold) |
image = | darkTopHat2dImg (inImg,inSEXY,inTopHatThreshold,inOptBorderExtensionPolicy) |
image = | lightTopHat2dImg (inImg,inSEXY,inTopHatThreshold) |
image = | lightTopHat2dImg (inImg,inSEXY,inTopHatThreshold,inOptBorderExtensionPolicy) |
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
, is associated to following formula :
- Dark (black) top hat transform :
Dark Top-Hat algorithm used a top-hat transform followed by a binarization step which can be illustrated as follow :
- Light (white) top hat transform :
White Top-Hat algorithm used a top-hat transform followed by a binarization step which can be illustrated as follow :
Where
and
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 :
- 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
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
structuringElement = PyIPSDK.circularSEXYInfo(15);
outImg = bin.darkTopHat2dImg(inImg, structuringElement, 20)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLBinarization/Processor/TopHat2dImg/TopHat2dImg.h>
Code Example
ImagePtr pOutImgDark = darkTopHat2dImg(pInImg, pInSEXY, 30);