![]() |
IPSDK
4_1_0_2
IPSDK : Image Processing Software Development Kit
|
module demonstrating shape analysis and measurement in 3d case More...
module demonstrating shape analysis and measurement in 3d case
This application computes measurements on 3d shapes from an input image TIFF files couple (a grey level and a binary image).
The application can be called through a command line as follows:
<application_exe_filename> [--inputGreyImgPath <input_grey_image_file_path>] [--inputBinImgPath <input_binary_image_file_path>] [--outputCsvResultPath <output csv result path>]
Arguments:
--inputGreyImgPath optional; specifies the name of the TIFF file, from
which the input 3d grey level image will be loaded; if not
specified by the user, the input image is loaded from
file
<DEV_ROOT>/data/Sample/images/blobs3d_483x348x31_UInt8.tif
--inputBinImgPath optional; specifies the name of the TIFF file, from
which the input 3d binary image will be loaded; if not
specified by the user, the input image is loaded from
file
<DEV_ROOT>/data/Sample/images/blobs3d_483x348x31_Binary.tif
--outputCsvResultPath optional; specifies the name of the CSV file, in
which the output analysis results will be saved; if not
specified by the user, the output results file is saved to
file
<TEMPORARY_IPSDK_DIR>/Sample/shapeAnalysis3d.csvWe start by including all the necessary header files:
In the main function body, we start by asking to display all the log messages generated by IPSDK libraries and by our application itself to the application console:
Next, we initialize the IPSDK environment by invoking "ipsdk::core::LibraryInitializer::getInstance().init()". This method must be called before using any entity or function of IPSDK libraries. It returns an object of type ipsdk::core::LibInitResult, that tells us whether the initialization was OK or not. If the initialization failed (because the IPSDK license file was not found, for instance), we notify the user with an appropriate log message, and we close the application.
We then initialize input paths through the call of the "readCmdArguments" function. As its name suggests, it parses the command line to initialize the input and output images files paths, depending on the options specified by the user. The definition of this function is not explained here, because it mainly uses boost functions, and no IPSDK code.
Once the IPSDK environment correctly initialized, we load our input images from the associated TIFF file.
We then apply a connected components algorithm on input binary image (see Connected Component 3d).
A contour based version of this 'labeled' image is then processed. User should note that a polyhedral approximation of surfaces is processed during previous step (see Label shape extraction 3d).
At last we define a collection of measures to be processed and we launch shape analysis (see Shape Analysis 3d).
Measure results can then be individually extracted from returned object MeasureSetPtr pOutMeasureSet as demonstrated by following code (extracted type must match measure results type, see measure result type associated to Area3d for example) :
Measure results can also be saved to file using CSV file format (for example) using following code :
The final action consists in cleaning the IPSDK environment before exiting. This cleaning operation (call to "ipsdk::core::LibraryInitializer::getInstance().clear()") must be the last call to IPSDK environment. It guarantees in particular that all threads created by IPSDK libraries are complete.
See the full source listing
1.8.14