![]() |
IPSDK
4_1_0_2
IPSDK : Image Processing Software Development Kit
|
module demonstrating shape filtering on 2d images More...
module demonstrating shape filtering on 2d images
This application proceeds to a shape filtering operation from an input image TIFF files cupple (a binary or label image and an optional grey level image) and a filtering formula.
The application can be called through a command line as follows:
<application_exe_filename> [--inputGreyImgPath <input_grey_image_file_path>] [--inputBinLabImgPath <input_binary_image_file_path>] [--inputFilterFormula <input_filter_formula>] [--outputImgFilePath <output_image_file_path>]
Arguments:
--inputGreyImgPath optional; specifies the name of the TIFF file, from
which the input grey level image will be loaded; if not
specified by the user, used input image is loaded from
file
<DEV_ROOT>/data/Sample/images/blobs_483x348_UInt8.tif
--inputBinLabImgPath optional; specifies the name of the TIFF file, from
which the input binary or label image will be loaded;
if not specified by the user, the input image is
loaded from file
<DEV_ROOT>/data/Sample/images/blobs_483x348_Binary.tif
--inputFilterFormula optional; specifies the formula string used to filter
shapes from input binary/label image.
if not specified by the user, the input filter formula
will be set to
Area2dMsr > 800
--outputImgFilePath optional; specifies the name of the TIFF file, in
which the output filtered image will be saved; if not
specified by the user, the output image file is saved
to file
<TEMPORARY_IPSDK_DIR>/Sample/shapeFiltering2dImg.tifHere is a snapshot of default input images used by the application and of corresponding output results with the following filtering criteria Circularity<0.9 and Mean<170:
Central displayed table correspond to the working data used during filtering operation.
We 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 the main shape filtering algorithm on input image using input formula string.
The resulting output image is then saved to the TIFF file specified in object "outputImgFilePath":
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