#include "HxImageRep.h"
Go to the source code of this file.
Functions | |
HxImageRep L_HXIMAGEREP | HxXor (HxImageRep im1, HxImageRep im2) |
Exclusive or. More... |
|
Exclusive or. The function performs exclusive or (see Pixels) on all pixels in the input images via a binary pixel operation (see Images). Implementation specifics : The pixel functor : HxBpoXor. The image functor instantiator : HxInstantiatorXor.
00015 { 00016 HxString fname("HxXor"); 00017 00018 if (im1.isNull()) 00019 { 00020 HxGlobalError::instance()->reportError(fname, im1.name(), "null image", HxGlobalError::HX_GE_INVALID); 00021 return HxImageRep(); 00022 } 00023 if (im2.isNull()) 00024 { 00025 HxGlobalError::instance()->reportError(fname, im2.name(), "null image", HxGlobalError::HX_GE_INVALID); 00026 return HxImageRep(); 00027 } 00028 00029 if (im1.signature().imageDimensionality() != im2.signature().imageDimensionality()) 00030 { 00031 HxGlobalError::instance()->reportError(fname, "unequal image dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00032 return HxImageRep(); 00033 } 00034 if (im1.signature().pixelDimensionality() != im2.signature().pixelDimensionality()) 00035 { 00036 HxGlobalError::instance()->reportError(fname, "unequal pixel dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00037 return HxImageRep(); 00038 } 00039 if (im1.signature().pixelDimensionality() != 1) 00040 { 00041 HxGlobalError::instance()->reportError(fname, "logical operators are only valid for scalar images", HxGlobalError::HX_GE_INVALID); 00042 return HxImageRep(); 00043 } 00044 00045 if (im1.signature().pixelType() != im2.signature().pixelType()) 00046 { 00047 HxGlobalError::instance()->reportError(fname, "unequal pixel types", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00048 return HxImageRep(); 00049 } 00050 if (im1.signature().pixelType() != INT_VALUE) 00051 { 00052 HxGlobalError::instance()->reportError(fname, "logical operators are only valid on integer values", HxGlobalError::HX_GE_INVALID); 00053 return HxImageRep(); 00054 } 00055 00056 if (im1.signature().pixelPrecision() != im2.signature().pixelPrecision()) 00057 { 00058 HxGlobalError::instance()->reportError(fname, "unequal pixel precisions", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00059 return HxImageRep(); 00060 } 00061 00062 if (im1.sizes().x() != im2.sizes().x()) 00063 { 00064 HxGlobalError::instance()->reportError(fname, "unequal image widths", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00065 return HxImageRep(); 00066 } 00067 if (im1.sizes().y() != im2.sizes().y()) 00068 { 00069 HxGlobalError::instance()->reportError(fname, "unequal image heights", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00070 return HxImageRep(); 00071 } 00072 if (im1.signature().imageDimensionality() > 2) 00073 { 00074 if (im1.sizes().z() != im2.sizes().z()) 00075 { 00076 HxGlobalError::instance()->reportError(fname, "unequal image depths", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00077 return HxImageRep(); 00078 } 00079 } 00080 00081 return im1.binaryPixOp(im2, "xor"); 00082 } |