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

HxSub.h File Reference

More...

#include "HxImageRep.h"

Go to the source code of this file.

Functions

HxImageRep L_HXIMAGEREP HxSub (HxImageRep im1, HxImageRep im2)
 Subtraction. More...


Detailed Description


Function Documentation

HxImageRep L_HXIMAGEREP HxSub HxImageRep    im1,
HxImageRep    im2
 

Subtraction.

The function performs subtraction (see Pixels) on all pixels in the input images via a binary pixel operation (see Images).

Implementation specifics : The pixel functor : HxBpoSub. The image functor instantiator : HxInstantiatorSub.

00016 {
00017     HxString fname("HxSub");
00018 
00019     if (im1.isNull())
00020     {
00021         HxGlobalError::instance()->reportError(fname, im1.name(), "null image", HxGlobalError::HX_GE_INVALID);
00022         return HxImageRep();
00023     }
00024     if (im2.isNull())
00025     {
00026         HxGlobalError::instance()->reportError(fname, im2.name(), "null image", HxGlobalError::HX_GE_INVALID);
00027         return HxImageRep();
00028     }
00029 
00030     if (im1.signature().imageDimensionality() != im2.signature().imageDimensionality())
00031     {
00032         HxGlobalError::instance()->reportError(fname, "unequal image dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES);
00033         return HxImageRep();
00034     }
00035     if (im1.signature().pixelDimensionality() != im2.signature().pixelDimensionality())
00036     {
00037         HxGlobalError::instance()->reportError(fname, "unequal pixel dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES);
00038         return HxImageRep();
00039     }
00040 //  if (im1.signature().pixelType() != im2.signature().pixelType())
00041 //  {
00042 //      HxGlobalError::instance()->reportError(fname, "unequal pixel types", HxGlobalError::HX_GE_UNEQUAL_IMAGETYPES);
00043 //      return HxImageRep();
00044 //  }
00045 //  if (im1.signature().pixelPrecision() != im2.signature().pixelPrecision())
00046 //  {
00047 //      HxGlobalError::instance()->reportError(fname, "unequal pixel precisions", HxGlobalError::HX_GE_UNEQUAL_IMAGETYPES);
00048 //      return HxImageRep();
00049 //  }
00050 
00051     if (im1.sizes().x() != im2.sizes().x())
00052     {
00053         HxGlobalError::instance()->reportError(fname, "unequal image widths", HxGlobalError::HX_GE_UNEQUAL_IMAGES);
00054         return HxImageRep();
00055     }
00056     if (im1.sizes().y() != im2.sizes().y())
00057     {
00058         HxGlobalError::instance()->reportError(fname, "unequal image heights", HxGlobalError::HX_GE_UNEQUAL_IMAGES);
00059         return HxImageRep();
00060     }
00061     if (im1.signature().imageDimensionality() > 2)
00062     {
00063         if (im1.sizes().z() != im2.sizes().z())
00064         {
00065             HxGlobalError::instance()->reportError(fname, "unequal image depths", HxGlobalError::HX_GE_UNEQUAL_IMAGES);
00066             return HxImageRep();
00067         }
00068     }
00069 
00070     // in case of byte, unsigned: generate warnings in case of potentially dangerous
00071     // situations.
00072     // Check if image is byte.
00073     if (((im1.signature().pixelType() == INT_VALUE) && 
00074          (im1.signature().pixelPrecision() == 8)) ||
00075         ((im2.signature().pixelType() == INT_VALUE) && 
00076          (im2.signature().pixelPrecision() == 8)))
00077     {
00078         if ((im1.pixelDimensionality() == 1) && (im1.pixelDimensionality() == 1))
00079         {
00080             if ((HxPixMin(im1).HxScalarIntValue() - 
00081                  HxPixMin(im2).HxScalarIntValue()) < HxScalarInt(0))
00082             {
00083                 HxGlobalError::instance()->reportWarning(fname, 
00084                     im1.name()+HxString(" ")+im2.name(), 
00085                     "possible underflow due to byte precision", 
00086                     HxGlobalError::HX_GW_OVERFLOW);
00087             }
00088         }
00089         else if ((HxPixMin(HxUnaryMin(im1)).HxScalarIntValue() - 
00090                   HxPixMin(HxUnaryMin(im2)).HxScalarIntValue()) < HxScalarInt(0))
00091         {
00092                 HxGlobalError::instance()->reportWarning(fname, 
00093                     im1.name()+HxString(" ")+im2.name(), 
00094                     "possible underflow due to byte precision", 
00095                     HxGlobalError::HX_GW_OVERFLOW);
00096         }
00097     } 
00098 
00099 
00100     return im1.binaryPixOp(im2, "sub");
00101 }


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