summaryrefslogtreecommitdiff
path: root/include/im_math_op.h
diff options
context:
space:
mode:
authorscuri <scuri>2009-10-01 02:56:38 +0000
committerscuri <scuri>2009-10-01 02:56:38 +0000
commit62783aee16f96fe5e513fb230b8efddaa02981df (patch)
tree9dc512b0c758025c5cddba9709420f1bf9058675 /include/im_math_op.h
parent9a5e93213e08601a58725f44035ac622fb68e849 (diff)
New: functions imProcessUnsharp and imProcessSharp.
Changed: now imProcessUnArithmeticOp, imProcessArithmeticConstOp and imProcessArithmeticOp willl crop the result to 0-255 if destiny has data type byte. Changed: removed IM_UN_INC operation from imProcessUnArithmeticOp. It was not an unary operation. Can simply be done in place by imProcessArithmeticOp and IM_BIN_ADD.
Diffstat (limited to 'include/im_math_op.h')
-rw-r--r--include/im_math_op.h15
1 files changed, 5 insertions, 10 deletions
diff --git a/include/im_math_op.h b/include/im_math_op.h
index f410c62..2a4794f 100644
--- a/include/im_math_op.h
+++ b/include/im_math_op.h
@@ -9,14 +9,12 @@
#include "im_complex.h"
-//#define IM_NEARZERO 0.0000001f
-//#define IM_NEARINF 10000000
/// Crop value to Byte limit
template <class T>
inline T crop_byte(const T& v)
{
- return v <= 0? 0: v <= 255? v: 255;
+ return v < 0? 0: v > 255? 255: v;
}
/// Generic Addition with 2 template types
@@ -44,7 +42,6 @@ inline T1 mul_op(const T1& v1, const T2& v2)
template <class T1, class T2>
inline T1 div_op(const T1& v1, const T2& v2)
{
-// if (v2 == 0) return (T1)IM_NEARINF;
return v1 / v2;
}
@@ -52,7 +49,6 @@ inline T1 div_op(const T1& v1, const T2& v2)
template <class T>
inline T inv_op(const T& v)
{
-// if (v == 0) return (T)IM_NEARINF;
return 1/v;
}
@@ -60,7 +56,7 @@ inline T inv_op(const T& v)
template <class T1, class T2>
inline T1 diff_op(const T1& v1, const T2& v2)
{
- if (v1 <= v2)
+ if (v1 < v2)
return v2 - v1;
return v1 - v2;
}
@@ -69,7 +65,7 @@ inline T1 diff_op(const T1& v1, const T2& v2)
template <class T1, class T2>
inline T1 min_op(const T1& v1, const T2& v2)
{
- if (v1 <= v2)
+ if (v1 < v2)
return v1;
return v2;
}
@@ -78,7 +74,7 @@ inline T1 min_op(const T1& v1, const T2& v2)
template <class T1, class T2>
inline T1 max_op(const T1& v1, const T2& v2)
{
- if (v1 <= v2)
+ if (v1 < v2)
return v2;
return v1;
}
@@ -109,7 +105,7 @@ inline T1 pow_op(const T1& v1, const T2& v2)
template <class T>
inline T abs_op(const T& v)
{
- if (v <= 0)
+ if (v < 0)
return -1*v;
return v;
}
@@ -161,7 +157,6 @@ inline int log(const int& v)
template <class T>
inline T log_op(const T& v)
{
-// if (v <= 0) return (T)IM_NEARINF;
return (T)log(v);
}