![]() |
IPSDK
4_1_0_2
IPSDK : Image Processing Software Development Kit
|
module demonstrating the image masking operation More...
module demonstrating the image masking operation
This application applies a binary mask on an input image and saves the result in a given TIFF file. Input image and binary mask are loaded from given TIFF files.
The application can be called through a command line as follows:
<application_exe_filename> [--inputImgFilePath <input_image_file_path>] [--maskImgFilePath <mask_image_file_path] [--outputImgFilePath <output_image_file_path>]
Arguments:
--inputImgFilePath optional; specifies the path of the TIFF file, from
which the input image will be loaded; if not
specified by the user, the input image is loaded from
file
<DEV_ROOT>/data/Sample/images/Lena_510x509_UInt8.tif
--maskImgFilePath optional; specifies the path of the TIFF file, from
which the binary image of mask will be loaded; if not
specified by the user, the input image is loaded from
file
<DEV_ROOT>/data/Sample/iamges/binary_mask.tif
--outputImgFilePath optional; specifies the name of the TIFF file, in
which the output image resulting from the
Otsu's binarization will be saved;
if not specified by the user, the output image is
saved in file
<TEMPORARY_IPSDK_DIR>/Sample/mask.tifHere is a snapshot of default input and mask images used by the application and of corresponding output image when application is launched without any argument:
The sequence of operations executed in this application is very similar to what is done in Lightness sample application:
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:
Then we declare objects 'inImgFilePath', 'maskImgFilePath' and 'outImgFilePath':
Paths are updated from the command line, by calling function "readCmdArguments":
And we load input image and binary mask image from the associated TIFF files:
Once input and mask images are loaded, we apply the masking operation, by calling "ipsdk::imaproc::logic::maskImg" function. The resulting output image is stored in variable pOutImg.
The call of this function is enclosed in a try/catch block, to handle the case where an exception is thrown. If an error occurs, a message is displayed to the user, IPSDK environment is cleaned by calling "ipsdk::core::LibraryInitializer::getInstance().clear()" and the application terminates.
The output image is then saved to the TIFF file specified in object "outImgFilePath":
Finally, we clean IPSDK environment and exit:
See the full source listing
1.8.14