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

Overview

This application equalizes an input image loaded from a given input TIFF file, and saves the result in a given TIFF file.

See also
equalization algorithm

Usage

The application can be called through a command line as follows:

   <application_script_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 image

Here is a snapshot of default input image used by the application and of corresponding output image when application is launched without any argument:

Sample_HistogramEqualization.png

Source code documentation

The sequence of operations executed in this application is very similar to what is done in Lightness sample application:

We start by importing all necessary libraries:

import os
import sys, getopt
import PyIPSDK
import PyIPSDK.IPSDKIPLIntensityTransform as itrans

Then we define the input parameters.

# retrieve program parameters
inputImgPath, outputImgPath, outImgMin, outImgMax = readCmdArguments(argv)

We load our input image from the associated Tiff file, by calling the function ipsdk::image::file::loadTiffImageFile.

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)

We then apply the histogram equalization calculation on the input image.

# definition of equalization range
equalizeRange = PyIPSDK.createRange(outImgMin, outImgMax)
# equalization image computation
outImg = itrans.equalize2dImg(inImg, equalizeRange)

Lastly, we save the image resulting from the operation to the Tiff file.

# save generated image
print("Writing result in file : " + outputImgPath)
PyIPSDK.saveTiffImageFile(outputImgPath, outImg)

See the full source listing