Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxGetColorChannel.h File Reference

More...

#include "HxImageRep.h"
#include "HxColorSpace.h"
#include "HxColor.h"

Go to the source code of this file.

Functions

HxImageRep L_HXIMAGEREP HxGetColorChannel (HxImageRep im, HxColorModel fromColorSpace, HxColorModel toColorSpace, int channel, int do_normalize)
 GetColorChannel. More...


Detailed Description


Function Documentation

HxImageRep L_HXIMAGEREP HxGetColorChannel HxImageRep    im,
HxColorModel    fromColorSpace,
HxColorModel    toColorSpace,
int    channel,
int    do_normalize
 

GetColorChannel.

The function converts an image to a different color model, extracts a channel and optionally normalizes it. Implementation specifics : The function is a sequence of other global functions.

00020 {
00021     HxString fname("HxGetColorChannel");
00022 
00023     if (im.isNull())
00024     {
00025         HxGlobalError::instance()->reportError(fname, im.name(), "null image", HxGlobalError::HX_GE_INVALID);
00026         return HxImageRep();
00027     }
00028     if (im.signature().pixelDimensionality() != 3)
00029     {
00030         HxGlobalError::instance()->reportError(fname, "ColorSpace conversions are only valid for Vec3 images", HxGlobalError::HX_GE_INVALID);
00031         return HxImageRep();
00032     }
00033     if ((channel < 1) || (channel > 3))
00034     {
00035         HxGlobalError::instance()->reportError(fname, "Channel must be between 1 and 3", HxGlobalError::HX_GE_INVALID);
00036         return HxImageRep();
00037     }
00038 
00039     HxTagList tags;
00040     HxAddTag<HxColorModel>(tags, "fromColorSpace", fromColorSpace);
00041     HxAddTag<HxColorModel>(tags, "toColorSpace", toColorSpace);
00042     im = HxImageAsVec3Double(im);
00043     HxImageRep im_conv = im.unaryPixOp("colorSpace", tags);
00044     if (!do_normalize)
00045     {
00046         return HxProjectRange(im_conv, channel);
00047     }
00048     return HxDiv(HxProjectRange(im_conv, channel), HxNorm1(im_conv));
00049 }


Generated on Tue Feb 3 14:18:48 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001