Shape extraction from label 3d image algorithm.
This algorithm allows to extract 3d shapes from a label (see Connected Component 3d) input 3d image. This extraction is a required step to be able to proceed to 3d shapes analysis (Shape Analysis 3d). Shapes extracted with this algorithm are then made of 2 parts:
- the set of x-aligned segments of voxels that constitute the shape, that is systematically computed; this set of row segments is afterwards used by the intensity measures (NbPixels3dMsr, for instance)
- an estimation of the surface(s) of the shape, that is optionally computed at the user's request (depending on the value of the parameter InOptEnableSurfaceExtraction). This estimation of the surface of the shape is then used by the geometrical measures (Area3d, Volume3d, Convexity, etc.). The result of this surface estimation is a set of polyhedrons, whose faces are triangles only (these polyhedrons are also called triangle meshes), computed with the "marching cubes" algorithm. The generated triangle meshes are always closed, even if the shape is sticked to the image border, and should be manifold (each edge of each mesh is shared by at most 2 triangles of the mesh).
Here is an example of a 3d shape extraction on our binary test image imageMorphoBin3d6.tif, on which a 3d connected component algorithm has been applied to get the associated label image:
- Note
- : the light blue ellipsoid and the dark blue sphere are drawn transparent, to see respectively the green shape behind the ellipsoid and the two holes inside the sphere.
imageMorphoBin3d6.tif is a 3d binary image (background in black, shapes in white), in which the following shapes were drawn:
- shape 1: a plain oriented box (center: (X=17, Y=16, Z=12), half-sizes: (HSX=10, HSY=7, HSZ=5), orientation: (chi=0, beta=pi/6, alpha=0))
- shape 2: addition of 3 plain axis-aligned boxes, arranged in a "U" shape:
- box 1: center (X=32, Y=50, Z=10), half-sizes=(HSX=15, HSY=5, HSZ=4)
- box 2: center (X=22, Y=50, Z=15), half-sizes=(HSX=5, HSY=5, HSZ=4)
- box 3: center (X=42, Y=50, Z=15), half-sizes=(HSX=5, HSY=5, HSZ=4)
- shape 3: a plain oriented ellipsoid (center: (X=50, Y=20, Z=21), dimensions:(a=12, b=10, c=5), orientation: (chi=pi/3, beta=pi/4, alpha=pi/5)
- shape 4: substraction plain axis-aligned box - ball
- box: corner (xmin=6, ymin=7, zmin=30), size (SX=25, SY=26, SZ=27)
- ball: center (X=31, Y=20, Z=43), radius=10
- shape 5: plain ball with 2 cube-shaped holes
- ball: center (X=44, Y=45, Z=50), radius=15
- hole 1: cube, center=(X=38, Y=45, Z=50), half-size=4
- hole 2: cube, center=(X=50, Y=45, Z=50), half-size=4
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLAdvancedMorphology as advmorpho
import PyIPSDK.IPSDKIPLShapeSegmentation as shapesegmentation
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
inLabelImg3d = advmorpho.connectedComponent3dImg(inImg)
outShape3dColl = shapesegmentation.labelShapeExtraction3d(inLabelImg3d)
simplifiedSurfaceExtractionSettings = PyIPSDK.createSimplifiedSurfaceExtractionSettings(0.9, 100)
outShape3dCollSimplified = shapesegmentation.labelShapeExtraction3d(inLabelImg3d, simplifiedSurfaceExtractionSettings)
coarseSurfaceExtractionSettings = PyIPSDK.createSubSampledSurfaceExtractionSettings(2)
outShape3dCollCoarse = shapesegmentation.labelShapeExtraction3d(inLabelImg3d, coarseSurfaceExtractionSettings)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLShapeSegmentation/Processor/LabelShapeExtraction3d/LabelShapeExtraction3d.h>
Code Example
ImagePtr pInBinImg3d =
loadTiffImageFile(inputBinImgPath, eTiffDirectoryMode::eTDM_Volume);
Shape3dCollPtr pOutColl = labelShapeExtraction3d(pInLabelImg3d, pSurfaceExtractionSettings);