#include "HxImageRep.h"
Go to the source code of this file.
Functions | |
| HxImageRep L_HXIMAGEREP | HxAdd (HxImageRep im1, HxImageRep im2) |
| Addition. More... | |
|
||||||||||||
|
Addition. The function performs addition (see Pixels) on all pixels in the input images via a binary pixel operation (see Images). Implementation specifics : The pixel functor : HxBpoAdd. The image functor instantiator : HxInstantiatorAdd.
00016 {
00017 HxString fname("HxAdd");
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.dimensionality() != im2.dimensionality())
00031 {
00032 HxGlobalError::instance()->reportError(fname, "unequal image dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES);
00033 return HxImageRep();
00034 }
00035 if (im1.pixelDimensionality() != im2.pixelDimensionality())
00036 {
00037 HxGlobalError::instance()->reportError(fname, "unequal pixel dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES);
00038 return HxImageRep();
00039 }
00040
00041 if (im1.sizes().x() != im2.sizes().x())
00042 {
00043 HxGlobalError::instance()->reportError(fname, "unequal image widths", HxGlobalError::HX_GE_UNEQUAL_IMAGES);
00044 return HxImageRep();
00045 }
00046 if (im1.sizes().y() != im2.sizes().y())
00047 {
00048 HxGlobalError::instance()->reportError(fname, "unequal image heights", HxGlobalError::HX_GE_UNEQUAL_IMAGES);
00049 return HxImageRep();
00050 }
00051 if (im1.dimensionality() > 2)
00052 {
00053 if (im1.sizes().z() != im2.sizes().z())
00054 {
00055 HxGlobalError::instance()->reportError(fname, "unequal image depths", HxGlobalError::HX_GE_UNEQUAL_IMAGES);
00056 return HxImageRep();
00057 }
00058 }
00059
00060 // in case of byte, unsigned: generate warnings in case of potentially dangerous
00061 // situations.
00062 // Check if image is byte.
00063
00064 if (((im1.signature().pixelType() == INT_VALUE) &&
00065 (im1.signature().pixelPrecision() == 8)) ||
00066 ((im2.signature().pixelType() == INT_VALUE) &&
00067 (im2.signature().pixelPrecision() == 8)))
00068 {
00069 if ((im1.pixelDimensionality() == 1) && (im1.pixelDimensionality() == 1))
00070 {
00071 if ((HxPixMax(im1).HxScalarIntValue() +
00072 HxPixMax(im2).HxScalarIntValue()) > HxScalarInt(255))
00073 {
00074 HxGlobalError::instance()->reportWarning(fname,
00075 im1.name()+HxString(" ")+im2.name(),
00076 "possible overflow due to byte precision",
00077 HxGlobalError::HX_GW_OVERFLOW);
00078 }
00079 }
00080 else if ((HxPixMax(HxUnaryMax(im1)).HxScalarIntValue() +
00081 HxPixMax(HxUnaryMax(im2)).HxScalarIntValue()) > HxScalarInt(255))
00082 {
00083 HxGlobalError::instance()->reportWarning(fname,
00084 im1.name()+HxString(" ")+im2.name(),
00085 "possible overflow due to byte precision",
00086 HxGlobalError::HX_GW_OVERFLOW);
00087 }
00088 }
00089
00090 return im1.binaryPixOp(im2, "add");
00091 }
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001