IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

keep only the big connected components in binary or label 2d image More...

IPSDKIPLADVANCEDMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::advmorpho::keepBigShape2dImg (const image::ImageConstPtr &pInBinLabImg, const ipUInt32 inNbFeatures)
 wrapper function for keep only the big connected components in binary or label 2d image More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API void ipsdk::imaproc::advmorpho::keepBigShape2dImg (const image::ImageConstPtr &pInBinLabImg, const ipUInt32 inNbFeatures, const image::ImagePtr &pOutImg)
 wrapper function for keep only the big connected components in binary or label 2d image More...
 

Detailed Description

keep only the big connected components in binary or label 2d image

This algorithm allows to remove the smallest connected components into a binary or label 2d input image, keeping only the inNbFeatures biggest features.

The output result image OutImg has same type as input image InBinLabImg. This means that an input binary image will produce an output binary image and that an input label image will produce an output label image. Note that in label case, input labels index are reordered to fill index list holes created by shape filtering . Moreover, the biggest the feature will be assigned to the lowest label and the smallest selected feature will be assigned to the highest label.

Here is an example of small connected component removal on an image 2d :

keepBigShape2dImg.png

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InBinLabImg [Input] binary or label image for processing operation X
ipsdk::imaproc::attr::InNbFeatures [Input] target number of features to be detected by algorithm X
ipsdk::imaproc::attr::OutOptWk1LabelImg [Output Optional] Temporary working image for algorithm X
ipsdk::imaproc::attr::OutImg [Output] image for processing operation duplicateInOut (_pOutImg, _pInBinLabImg)

Global Rule description

Global rule description for algorithm :
((ipsdk::imaproc::matchSizeAndType (_pInBinLabImg,_pOutImg)) && 
 (ipsdk::processor::ifIsSet (
   _pOutOptWk1LabelImg, (
    ipsdk::imaproc::matchSize (_pInBinLabImg,_pOutOptWk1LabelImg)))))

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLAdvancedMorphology as advmorpho

Code Example

# opening of input image
inBinImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# compute the selection on a binary image
# note: algorithm can also be used with input label image
outBinImg = advmorpho.keepBigShape2dImg(inBinImg, 4)

Example of C++ code :

Example informations

Associated library

IPSDKIPLAdvancedMorphology

Header file

Code Example

// opening input image
ImagePtr pInBinImg = loadTiffImageFile(inputImgPath);
// compute the selection on a binary image
// note: algorithm can also be used with input label image
ImagePtr pOutImg = keepBigShape2dImg(pInBinImg, 4);
See also
KeepBigShape2dImgLvl1
KeepBigShape2dImgLvl2

Function Documentation

◆ keepBigShape2dImg() [1/2]

IPSDKIPLADVANCEDMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::advmorpho::keepBigShape2dImg ( const image::ImageConstPtr pInBinLabImg,
const ipUInt32  inNbFeatures 
)

wrapper function for keep only the big connected components in binary or label 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ keepBigShape2dImg() [2/2]

IPSDKIPLADVANCEDMORPHOLOGY_API void ipsdk::imaproc::advmorpho::keepBigShape2dImg ( const image::ImageConstPtr pInBinLabImg,
const ipUInt32  inNbFeatures,
const image::ImagePtr pOutImg 
)

wrapper function for keep only the big connected components in binary or label 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure