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