Horus Doc || Global Function Guide || General documentation   | Function documentation  

HxContrastStretch

Synopsis

HxImageRep HxContrastStretch (HxImageRep img, double mFactor)

Input

HxImageRep img
The image you want to improve the contrast of.

double mFactor
The maximum value in the output image. The minimum value is zero.

Return value

HxImageRep
An image with a range as given by mFactor for the pixel values.

Description

This function stretches the contrast of the function, where the range of the pixel value in the output image is given by the interval [0, mFactor]. The pixel value `y' in the output image is calculated from the original pixel value `x' as follows: Where and denote the minimum and maximum value of the input image. This function is defined for scalar images that are not constant.

Remarks

Valid input images
Only scalar images are valid, where the minimum and the maximum value in the image may not be equal.

Valid value for mFactor
mFactor should be larger than zero.

Examples

Example of stretching the contrast of an image

#include "HxImageRepGlobalFuncs.h"
#include "HxImageRep.h"

HxImageRep HxContrastStretchExample1(HxImageRep img) {
   img = HxImageAsDouble(img);
   img = HxContrastStretch(img, 150.0);
   img = HxImageAsByte(img);

   return img;
}

int main(int argc, char* argv[])
{
    HxImageRep im1 = HxMakeFromFile(argv[1]);
    im1 = HxContrastStretchExample1(im1);
    HxWriteFile(im1, argv[2]);

    return 0;
}

exampleImage1.gif

Input image for the HxContrastStretch example.

HxContrastStretchResult1.gif

Output image of the HxContrastStretch example.

In this example we stretch the pixel values to a range from 0 to 150.

See also

Keywords

Enhancement,


Generated on Mon Jan 27 15:44:59 2003 for GlobalFunctionGuide by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001