#include "HxImageRep.h"
Go to the source code of this file.
Functions | |
HxImageRep L_HXIMAGEREP | HxDivVal (HxImageRep im, HxValue val) |
Division. More... |
|
Division. The function performs division (see Pixels) on all pixels in the input image via a binary pixel operation (see Images). Implementation specifics : The pixel functor : HxBpoDiv. The image functor instantiator : HxInstantiatorDivV.
00013 { 00014 HxString fname("HxDivVal"); 00015 00016 if (im.isNull()) 00017 { 00018 HxGlobalError::instance()->reportError(fname, im.name(), "null image", HxGlobalError::HX_GE_INVALID); 00019 return HxImageRep(); 00020 } 00021 00022 int valdim; 00023 if ((val.tag() == HxValue::SI) || (val.tag() == HxValue::SD)) 00024 { 00025 valdim = 1; 00026 } 00027 else if ((val.tag() == HxValue::V2I) || (val.tag() == HxValue::V2D)) 00028 { 00029 valdim = 2; 00030 } 00031 else 00032 { 00033 valdim = 3; 00034 } 00035 if ((valdim != 1) && (im.signature().pixelDimensionality() != valdim)) 00036 { 00037 HxGlobalError::instance()->reportError(fname, "pixel dimensionality differs from value dimensionality", 00038 HxGlobalError::HX_GE_UNEQUAL_DIMS); 00039 return HxImageRep(); 00040 } 00041 00042 if (val.tag() == HxValue::SI) 00043 { 00044 if (((HxScalarInt) val) == HxScalarInt(0)) 00045 { 00046 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00047 return HxImageRep(); 00048 } 00049 } 00050 else if (val.tag() == HxValue::SD) 00051 { 00052 if (((HxScalarDouble) val) == HxScalarDouble(0.0)) 00053 { 00054 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00055 return HxImageRep(); 00056 } 00057 } 00058 else if (val.tag() == HxValue::V2I) 00059 { 00060 if (((HxVec2Int) val).x() == 0) 00061 { 00062 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00063 return HxImageRep(); 00064 } 00065 if (((HxVec2Int) val).y() == 0) 00066 { 00067 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00068 return HxImageRep(); 00069 } 00070 } 00071 else if ((val.tag() == HxValue::V2D) || (val.tag() == HxValue::CPL)) 00072 { 00073 if (((HxVec2Double) val).x() == 0.0) 00074 { 00075 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00076 return HxImageRep(); 00077 } 00078 if (((HxVec2Double) val).y() == 0.0) 00079 { 00080 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00081 return HxImageRep(); 00082 } 00083 00084 } 00085 else if (val.tag() == HxValue::V3I) 00086 { 00087 if (((HxVec3Int) val).x() == 0) 00088 { 00089 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00090 return HxImageRep(); 00091 } 00092 if (((HxVec3Int) val).y() == 0) 00093 { 00094 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00095 return HxImageRep(); 00096 } 00097 if (((HxVec3Int) val).z() == 0) 00098 { 00099 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00100 return HxImageRep(); 00101 } 00102 } 00103 else if (val.tag() == HxValue::V3D) 00104 { 00105 if (((HxVec3Double) val).x() == 0.0) 00106 { 00107 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00108 return HxImageRep(); 00109 } 00110 if (((HxVec3Double) val).y() == 0.0) 00111 { 00112 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00113 return HxImageRep(); 00114 } 00115 if (((HxVec3Double) val).z() == 0.0) 00116 { 00117 HxGlobalError::instance()->reportError(fname, "division by zero", HxGlobalError::HX_GE_INVALID); 00118 return HxImageRep(); 00119 } 00120 } 00121 00122 return im.binaryPixOp(val, "div"); 00123 } |