From 62783aee16f96fe5e513fb230b8efddaa02981df Mon Sep 17 00:00:00 2001 From: scuri Date: Thu, 1 Oct 2009 02:56:38 +0000 Subject: 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. --- include/im_math_op.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'include/im_math_op.h') 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 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 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 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 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 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 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 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 inline T log_op(const T& v) { -// if (v <= 0) return (T)IM_NEARINF; return (T)log(v); } -- cgit v1.2.3