image = | adaptiveThresholdMean3dImg (inImg3d,halfKnlSize) |
binarize a 3d input image according an adaptive threshold based on the mean intensity of the voxel's neighbourhood
For each voxel, the algorithm computes a threshold according to a neighbourhood described by
. The computed threshold
is the mean intensity along the voxel's neighbourhood
:
Where
is the number of voxels in
.
This algorithm is equivalent to the Adaptive Threshold 3d binarization algorithm, with each kernel coefficient set to
. However, it is optimized to compute a mean adaptive threshold based binarization and yields better performances.
- Note
- To avoid a noisy binarization, it is advised to filter the input image with a median filter before computing the binarization.
See Adaptive Threshold Mean 2d for a 2d example of the adaptative mean threshold result.
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLBinarization as bin
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
outImg = bin.adaptiveThresholdMean3dImg(inImg, halfKnlSize)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLBinarization/Processor/AdaptiveThresholdMean3dImg/AdaptiveThresholdMean3dImg.h>
Code Example
ImagePtr pAutoOutImg = adaptiveThresholdMean3dImg(pInImg, halfKnlSize);
const ipUInt64 sizeX = pInImg->getSizeX();
const ipUInt64 sizeY = pInImg->getSizeY();
const ipUInt64 sizeZ = pInImg->getSizeZ();
boost::shared_ptr<MemoryImage> pOutImg(boost::make_shared<MemoryImage>());
pOutImg->init(*pOutputImageGeometry);
adaptiveThresholdMean3dImg(pInImg, halfKnlSize, pOutImg);