#include "HxImageRep.h"
Go to the source code of this file.
Functions | |
HxImageRep L_HXIMAGEREP | HxPow (HxImageRep im1, HxImageRep im2) |
Power. More... |
|
Power. The function performs power (see Pixels) on all pixels in the input images via a binary pixel operation (see Images). Implementation specifics : The pixel functor : HxBpoPow. The image functor instantiator : HxInstantiatorPow.
00013 { 00014 HxString fname("HxPow"); 00015 00016 if (im1.isNull()) 00017 { 00018 HxGlobalError::instance()->reportError(fname, im1.name(), "null image", HxGlobalError::HX_GE_INVALID); 00019 return HxImageRep(); 00020 } 00021 if (im2.isNull()) 00022 { 00023 HxGlobalError::instance()->reportError(fname, im2.name(), "null image", HxGlobalError::HX_GE_INVALID); 00024 return HxImageRep(); 00025 } 00026 00027 if (im1.dimensionality() != im2.dimensionality()) 00028 { 00029 HxGlobalError::instance()->reportError(fname, "unequal image dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00030 return HxImageRep(); 00031 } 00032 if ((im1.pixelDimensionality() != im2.pixelDimensionality()) && 00033 (im2.pixelDimensionality() != 1)) 00034 { 00035 HxGlobalError::instance()->reportError(fname, "unequal pixel dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00036 return HxImageRep(); 00037 } 00038 00039 if (im1.sizes().x() != im2.sizes().x()) 00040 { 00041 HxGlobalError::instance()->reportError(fname, "unequal image widths", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00042 return HxImageRep(); 00043 } 00044 if (im1.sizes().y() != im2.sizes().y()) 00045 { 00046 HxGlobalError::instance()->reportError(fname, "unequal image heights", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00047 return HxImageRep(); 00048 } 00049 if (im1.dimensionality() > 2) 00050 { 00051 if (im1.sizes().z() != im2.sizes().z()) 00052 { 00053 HxGlobalError::instance()->reportError(fname, "unequal image depths", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00054 return HxImageRep(); 00055 } 00056 } 00057 00058 // in case of byte, unsigned: generate warnings in case of potentially dangerous 00059 // situations. 00060 // Check if image is byte. 00061 if (((im1.signature().pixelType() == INT_VALUE) && 00062 (im1.signature().pixelPrecision() == 8)) || 00063 ((im2.signature().pixelType() == INT_VALUE) && 00064 (im2.signature().pixelPrecision() == 8))) 00065 { 00066 if ((im1.pixelDimensionality() == 1) && (im1.pixelDimensionality() == 1)) 00067 { 00068 if (pow(HxPixMax(im1).HxScalarIntValue().x(), 00069 HxPixMax(im2).HxScalarIntValue().x()) > 255) 00070 { 00071 HxGlobalError::instance()->reportWarning(fname, 00072 im1.name()+HxString(" ")+im2.name(), 00073 "possible overflow due to byte precision", 00074 HxGlobalError::HX_GW_OVERFLOW); 00075 } 00076 } 00077 else if (pow(HxPixMax(HxUnaryMax(im1)).HxScalarIntValue().x(), 00078 HxPixMax(HxUnaryMax(im2)).HxScalarIntValue().x()) > 255) 00079 { 00080 HxGlobalError::instance()->reportWarning(fname, 00081 im1.name()+HxString(" ")+im2.name(), 00082 "possible overflow due to byte precision", 00083 HxGlobalError::HX_GW_OVERFLOW); 00084 } 00085 } 00086 00087 return im1.binaryPixOp(im2, "pow"); 00088 } |