![]() |
IPSDK
4_1_0_2
IPSDK : Image Processing Software Development Kit
|
module demonstrating the equalization of an image More...
module demonstrating the equalization of an image
This application equalizes an input image loaded from a given input TIFF file, and saves the result in a given TIFF file.
The application can be called through a command line as follows:
<application_exe_filename> [--inputImgFilePath <input_image_file_path>] [--outputImgFilePath <output_image_file_path>] [--outImgMin <min_value>] [--outImgMax <max_value>]
Arguments:
--inputImgFilePath optional; specifies the name 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_RGB_510x509_UInt8.tif
--outputImgFilePath optional; specifies the name of the TIFF file, in
which the output image resulting from the
computation of the lightness will be saved;
if not specified by the user, the output image is
saved in file
<TEMPORARY_IPSDK_DIR>/Sample/lightness.tif
--outImgMin optional (default value=0.0); expected mininum of output
image
--outImgMax optional (default value = 255.0); expected maximum of
output imageHere is a snapshot of default input image 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' and 'outImgFilePath':
We also declare 2 variables, that will respectively store the expected minimal and maximal pixel values of output image:
Paths and output image range values are updated from the command line, by calling function "readCmdArguments":
And we load our input image from the associated TIFF file:
Once our input image is loaded and the expected output image dynamic range is initialized, we equalize the input image by calling the function "ipsdk::imaproc::itrans::equalizeImg". "equalizeImg" function requires as arguments an input image, of type ImagePtr, and an expected output image dynamic range, of type RangePtr (that is a typedef for boost::shared_ptr<util::Range>). So we create a variable pInOutputRange, of type RangePtr, that we allocate through the call to "boost::make_shared<util::Range>()" and that we initialize thanks to the 2 successive calls to "pInOutputRange->setValue<util::Range::Min>(fOutImgMin);" and "pInOutputRange->setValue<util::Range::Max>(fOutImgMax);".
The call of the "equalizeImg" 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