IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Adaptive Threshold 3d binarization

Binarize a 3d input image according an adaptive threshold based on the voxel's neighbourhood. More...

IPSDKIPLBINARIZATION_API ipsdk::image::ImagePtr ipsdk::imaproc::bin::adaptiveThreshold3dImg (const ipsdk::image::ImageConstPtr &pInImg3d, const KernelXYZConstPtr &pInKnlXYZ)
 wrapper function for Binarize a 3d input image according an adaptive threshold based on the voxel's neighbourhood More...
 
IPSDKIPLBINARIZATION_API void ipsdk::imaproc::bin::adaptiveThreshold3dImg (const image::ImageConstPtr &pInImg3d, const KernelXYZConstPtr &pInKnlXYZ, const ipsdk::image::ImagePtr &pOutBinImg)
 wrapper function for Binarize a 3d input image according an adaptive threshold based on the voxel's neighbourhood More...
 
IPSDKIPLBINARIZATION_API ipsdk::image::ImagePtr ipsdk::imaproc::bin::adaptiveThresholdGaussian3dImg (const ipsdk::image::ImageConstPtr &pInImg3d, const ipUInt64 halfKnlSize)
 wrapper function for Binarize a 3d input image according an adaptive threshold based on the voxel's neighbourhood. Here, the threshold is defined as the sum of the intensities on the neighbourhood, weighted by Gaussian coefficients. The Gaussian coefficients are computed with the folowing standard deviation : $ 0.3*(halfKnlSize - 1) + 0.8 $ More...
 
IPSDKIPLBINARIZATION_API void ipsdk::imaproc::bin::adaptiveThresholdGaussian3dImg (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 voxel's neighbourhood. Here, the threshold is defined as the sum of the intensities on the neighbourhood, weighted by Gaussian coefficients. The Gaussian coefficients are computed with the folowing standard deviation : $ 0.3*(halfKnlSize - 1) + 0.8 $ More...
 

Detailed Description

Binarize a 3d input image according an adaptive threshold based on the voxel's neighbourhood.

For each voxel, the algorithm computes a threshold $T$ according to a neighbourhood described by the input kernel size as follows :

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

Where $\aleph$ is the voxel's neighbourhood.

Note
The kernels coefficients must be normalized :

\[ \sum_{(i, j, k) \in \aleph}{InKnlXY(i, j, k)} = 1\]

For example, the threshold can be the mean intensity in the neighbourhood with each kernel coefficients set to $1/N$, with $N$ being the number of voxels in the neighbourhood.

It is also possible to call the adaptiveThresholdGaussian3dImg wrapper, which needs the half kernel size instead of the kernel as input data. In this case, a predifined Gaussian kernel is used, whose coefficients are computed with the folowing standard deviation $\sigma$ (see http://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html#Mat%20getGaussianKernel%28int%20ksize,%20double%20sigma,%20int%20ktype%29) :

\[ \sigma = 0.3*((KnlSize-1)*0.5 - 1) + 0.8 \]

Where $KnlSize$ is the kernel size : $ N = KnlSize \times KnlSize \times KnlSize $.

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 2d binarization for a 2d example of the adaptative 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::InKnlXYZ [Input] kernel xyz for processing operation 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)
# Define the kernel according to a coefficients collection
inKnl = PyIPSDK.rectangularKernelXYZ(halfKnlSize, halfKnlSize, halfKnlSize, coeffColl)
# threshold computation with a given kernel
outImg = bin.adaptiveThreshold3dImg(inImg, inKnl)
# threshold computation with a predifined Gaussian kernel
outImgGauss = bin.adaptiveThresholdGaussian3dImg(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 = adaptiveThreshold3dImg(pInImg, pInKnlXYZ);
// Sample with a provided output image
// -----------------------------------
// 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
adaptiveThreshold3dImg(pInImg, pInKnlXYZ, pOutImg);
// Sample with an automatically computed
// Gaussian kernel and a generated output image
// --------------------------------------------
// compute absolute value of input image
ImagePtr pAutoGaussOutImg = adaptiveThresholdGaussian3dImg(pInImg, halfKnlSize);
See also
AdaptiveThreshold3dImgLvl1
AdaptiveThreshold3dImgLvl2
AdaptiveThreshold3dImgLvl3

Function Documentation

◆ adaptiveThreshold3dImg() [1/2]

IPSDKIPLBINARIZATION_API ipsdk::image::ImagePtr ipsdk::imaproc::bin::adaptiveThreshold3dImg ( const ipsdk::image::ImageConstPtr pInImg3d,
const KernelXYZConstPtr pInKnlXYZ 
)

wrapper function for Binarize a 3d input image according an adaptive threshold based on the voxel's neighbourhood

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ adaptiveThresholdGaussian3dImg() [1/2]

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

wrapper function for Binarize a 3d input image according an adaptive threshold based on the voxel's neighbourhood. Here, the threshold is defined as the sum of the intensities on the neighbourhood, weighted by Gaussian coefficients. The Gaussian coefficients are computed with the folowing standard deviation : $ 0.3*(halfKnlSize - 1) + 0.8 $

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ adaptiveThreshold3dImg() [2/2]

IPSDKIPLBINARIZATION_API void ipsdk::imaproc::bin::adaptiveThreshold3dImg ( const image::ImageConstPtr pInImg3d,
const KernelXYZConstPtr pInKnlXYZ,
const ipsdk::image::ImagePtr pOutBinImg 
)

wrapper function for Binarize a 3d input image according an adaptive threshold based on the voxel's neighbourhood

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ adaptiveThresholdGaussian3dImg() [2/2]

IPSDKIPLBINARIZATION_API void ipsdk::imaproc::bin::adaptiveThresholdGaussian3dImg ( 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 voxel's neighbourhood. Here, the threshold is defined as the sum of the intensities on the neighbourhood, weighted by Gaussian coefficients. The Gaussian coefficients are computed with the folowing standard deviation : $ 0.3*(halfKnlSize - 1) + 0.8 $

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure