IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

binarize a 3d input image according an adaptive threshold based on the mean intensity of the voxel's neighbourhood More...

IPSDKIPLBINARIZATION_API ipsdk::image::ImagePtr ipsdk::imaproc::bin::adaptiveThresholdMean3dImg (const ipsdk::image::ImageConstPtr &pInImg3d, const ipUInt64 halfKnlSize)
 wrapper function for binarize a 3d input image according an adaptive threshold based on the mean intensity of the voxel's neighbourhood More...
 
IPSDKIPLBINARIZATION_API void ipsdk::imaproc::bin::adaptiveThresholdMean3dImg (const image::ImageConstPtr &pInImg3d, const ipUInt64 halfKnlSize, const ipsdk::image::ImagePtr &pOutBinImg)
 wrapper function for binarize a 3d input image according an adaptive threshold based on the mean intensity of the voxel's neighbourhood More...
 

Detailed Description

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 $InKnlSize$. The computed threshold $T$ is the mean intensity along the voxel's neighbourhood $\aleph$ :

\[ T(x, y, z) = \frac{1}{N} \sum_{(i, j, k) \in \aleph}{InImg(x+i, y+j, z+k)} \]

Where $N$ is the number of voxels in $\aleph$.

This algorithm is equivalent to the Adaptive Threshold 3d binarization algorithm, with each kernel coefficient set to $1/N$. 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.

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg3d [Input] 3d image for operation X
ipsdk::imaproc::attr::InHalfKnlSize [Input] half kernel size (square or cubic kernel) X
ipsdk::imaproc::attr::OutBinImg [Output] binary image for processing operation ipsdk::imaproc::duplicateInOut (_pOutBinImg, _pInImg3d, image::eImageBufferType::eIBT_Binary)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSize (_pInImg3d,_pOutBinImg)

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 with a given kernel
outImg = bin.adaptiveThresholdMean3dImg(inImg, halfKnlSize)

Example of C++ code :

Example informations

Associated library

IPSDKIPLBinarization

Header file

Code Example

// Sample with a generated output image
// ------------------------------------
// compute absolute value of input image
ImagePtr pAutoOutImg = adaptiveThresholdMean3dImg(pInImg, halfKnlSize);
// Sample with a provided output image
// -----------------------------------
// Retrieve the input image size
const ipUInt64 sizeX = pInImg->getSizeX();
const ipUInt64 sizeY = pInImg->getSizeY();
const ipUInt64 sizeZ = pInImg->getSizeZ();
// create output image
ImageGeometryPtr pOutputImageGeometry = geometry3d(eImageBufferType::eIBT_Binary, sizeX, sizeY, sizeZ);
boost::shared_ptr<MemoryImage> pOutImg(boost::make_shared<MemoryImage>());
pOutImg->init(*pOutputImageGeometry);
// compute absolute value of input image
adaptiveThresholdMean3dImg(pInImg, halfKnlSize, pOutImg);
See also
AdaptiveThresholdMean3dImgLvl1
AdaptiveThresholdMean3dImgLvl2
AdaptiveThresholdMean3dImgLvl3

Function Documentation

◆ adaptiveThresholdMean3dImg() [1/2]

IPSDKIPLBINARIZATION_API ipsdk::image::ImagePtr ipsdk::imaproc::bin::adaptiveThresholdMean3dImg ( const ipsdk::image::ImageConstPtr pInImg3d,
const ipUInt64  halfKnlSize 
)

wrapper function for binarize a 3d input image according an adaptive threshold based on the mean intensity of the voxel's neighbourhood

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ adaptiveThresholdMean3dImg() [2/2]

IPSDKIPLBINARIZATION_API void ipsdk::imaproc::bin::adaptiveThresholdMean3dImg ( const image::ImageConstPtr pInImg3d,
const ipUInt64  halfKnlSize,
const ipsdk::image::ImagePtr pOutBinImg 
)

wrapper function for binarize a 3d input image according an adaptive threshold based on the mean intensity of the voxel's neighbourhood

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure