Algorithm for image 2d closing.
Morphological closing of an image by a given structuring element InSEXY is defined as the erosion of the dilation of image by InSEXY :
See Erosion 2d and Dilation 2d respectively for more informations about these operations.
- 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 closing 2d extraction operation applied to a binary input image with a circular structuring element with radius 15 :
In this example we can see that such an operation can be used to :
- reconnect particules weakly separated
- fill cavities of concave objects
- fill holes into particules
This morphological operation can also be used to detect oriented particules. This is illustrated with following example where a synthetic input has been processed with a linear structuring element with radius 5 and a 30 degrees orientation :
- Note
- By default this algorithm uses a fast but inexact method to handle data for which a contact may be created with image borders after first dilation step. Indeed, dilation step do not allows to keep a notion of deepness of such created image border contacts and then erosion step may keep these contacts when it should not. To avoid such errors user can set input algorithm parameter InOptBorderExtensionPolicy to value ipsdk::imaproc::attr::eBorderExtensionPolicy::eBEP_Enable. This will allow to handle exactly previous case at the cost of some computing times and of an additional allocated enlarged image. Here is an example of such problems, note contact created on right ellipse with fast method, and adjusted result with border extension method enabled :
- See also
- http://en.wikipedia.org/wiki/Closing_%28morphology%29
- Note
- This algorithm is associated with two temporary working images. These working temporary images can be provided by user or will be automatically allocated when requested.
- ipsdk::imaproc::attr::OutOptWk1Img will only be used if InOptBorderExtensionPolicy is set to ipsdk::imaproc::attr::eBorderExtensionPolicy::eBEP_Enable.
- 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.
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLBasicMorphology as morpho
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
inSE = PyIPSDK.circularSEXYInfo(8)
outImg = morpho.closing2dImg(inImg, inSE)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLBasicMorphology/Processor/Closing2dImg/Closing2dImg.h>
Code Example
ImagePtr pOutImg = closing2dImg(pInImg, pInSEXY);