#include "HxImageRep.h"
Go to the source code of this file.
Functions | |
HxImageRep L_HXIMAGEREP | HxDiv (HxImageRep im1, HxImageRep im2) |
Division. More... |
|
Division. The function performs division (see Pixels) on all pixels in the input images via a binary pixel operation (see Images). Implementation specifics : The pixel functor : HxBpoDiv. The image functor instantiator : HxInstantiatorDiv.
00013 { 00014 HxString fname("HxDiv"); 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 00033 if ((im1.pixelDimensionality() != im2.pixelDimensionality()) && 00034 (im2.pixelDimensionality() != 1)) 00035 { 00036 HxGlobalError::instance()->reportError(fname, "unequal pixel dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00037 return HxImageRep(); 00038 } 00039 00040 if (im1.sizes().x() != im2.sizes().x()) 00041 { 00042 HxGlobalError::instance()->reportError(fname, "unequal image widths", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00043 return HxImageRep(); 00044 } 00045 if (im1.sizes().y() != im2.sizes().y()) 00046 { 00047 HxGlobalError::instance()->reportError(fname, "unequal image heights", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00048 return HxImageRep(); 00049 } 00050 if (im1.dimensionality() > 2) 00051 { 00052 if (im1.sizes().z() != im2.sizes().z()) 00053 { 00054 HxGlobalError::instance()->reportError(fname, "unequal image depths", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00055 return HxImageRep(); 00056 } 00057 } 00058 00059 HxValue minval = HxPixMin(HxAbs(im2)); 00060 if (im2.pixelDimensionality() == 1) 00061 { 00062 if (im2.pixelType() == INT_VALUE) 00063 { 00064 if (( (HxScalarInt) minval) == 0) 00065 { 00066 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00067 return HxImageRep(); 00068 } 00069 } 00070 } 00071 else if (im2.pixelDimensionality() == 2) 00072 { 00073 if (im2.pixelType() == INT_VALUE) 00074 { 00075 if (( (HxVec2Int) minval).getValue(1) == 0) 00076 { 00077 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00078 return HxImageRep(); 00079 } 00080 else if (( (HxVec2Int) minval).getValue(2) == 0) 00081 { 00082 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00083 return HxImageRep(); 00084 } 00085 00086 } 00087 } 00088 else if (im2.pixelDimensionality() == 3) 00089 { 00090 if (im2.pixelType() == INT_VALUE) 00091 { 00092 if (( (HxVec3Int) minval).getValue(1) == 0) 00093 { 00094 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00095 return HxImageRep(); 00096 } 00097 else if (( (HxVec3Int) minval).getValue(2) == 0) 00098 { 00099 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00100 return HxImageRep(); 00101 } 00102 else if (( (HxVec3Int) minval).getValue(3) == 0) 00103 { 00104 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00105 return HxImageRep(); 00106 } 00107 00108 } 00109 } 00110 00111 return im1.binaryPixOp(im2, "div"); 00112 } |