summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/im_complex.h20
-rw-r--r--include/im_math_op.h15
-rw-r--r--include/im_process_loc.h29
-rw-r--r--include/im_process_pon.h20
4 files changed, 68 insertions, 16 deletions
diff --git a/include/im_complex.h b/include/im_complex.h
index 2ac4d92..1328dd5 100644
--- a/include/im_complex.h
+++ b/include/im_complex.h
@@ -54,6 +54,26 @@ inline int operator <= (const imcfloat& C, const float& F)
return ((F <= C.real) && (0 <= C.imag));
}
+inline int operator < (const imcfloat& C1, const imcfloat& C2)
+{
+ return ((C1.real < C2.real) && (C1.imag < C2.imag));
+}
+
+inline int operator < (const imcfloat& C, const float& F)
+{
+ return ((F < C.real) && (0 < C.imag));
+}
+
+inline int operator > (const imcfloat& C1, const imcfloat& C2)
+{
+ return ((C1.real > C2.real) && (C1.imag > C2.imag));
+}
+
+inline int operator > (const imcfloat& C, const float& F)
+{
+ return ((F > C.real) && (0 > C.imag));
+}
+
inline imcfloat operator + (const imcfloat& C1, const imcfloat& C2)
{
return imcfloat(C1.real + C2.real, C1.imag + C2.imag);
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);
}
diff --git a/include/im_process_loc.h b/include/im_process_loc.h
index 9c0531b..44e8281 100644
--- a/include/im_process_loc.h
+++ b/include/im_process_loc.h
@@ -569,6 +569,35 @@ int imGaussianStdDev2KernelSize(float stddev);
* \ingroup convolve */
float imGaussianKernelSize2StdDev(int kernel_size);
+/** Edge enhancement using Unsharp mask. stddev control the gaussian filter,
+ * amount controls how much the edges will enhance the image (0<amount<1), and
+ * threshold controls which edges will be considered, it compares to twice of the absolute size of the edge.
+ * Although very similar to \ref imProcessSharp, produces better results.
+ *
+ * \verbatim im.ProcessUnsharp(src_image: imImage, dst_image: imImage, stddev: number, amount: number, threshold: number) [in Lua 5] \endverbatim
+ * \verbatim im.ProcessUnsharpNew(image: imImage, stddev: number, amount: number, threshold: number) -> new_image: imImage [in Lua 5] \endverbatim
+ * \ingroup convolve */
+int imProcessUnsharp(const imImage* src_image, imImage* dst_image, float stddev, float amount, float threshold);
+
+/** Edge enhancement using Laplacian8 mask.
+ * amount controls how much the edges will enhance the image (0<amount<1), and
+ * threshold controls which edges will be considered, it compares to twice of the absolute size of the edge.
+ *
+ * \verbatim im.ProcessSharp(src_image: imImage, dst_image: imImage, amount: number, threshold: number) [in Lua 5] \endverbatim
+ * \verbatim im.ProcessSharpNew(image: imImage, amount: number, threshold: number) -> new_image: imImage [in Lua 5] \endverbatim
+ * \ingroup convolve */
+int imProcessSharp(const imImage* src_image, imImage* dst_image, float amount, float threshold);
+
+/** Edge enhancement using a given kernel.
+ * If kernel has all positive values, then the unsharp technique is used, else sharp is used.
+ * amount controls how much the edges will enhance the image (0<amount<1), and
+ * threshold controls which edges will be considered, it compares to twice of the absolute size of the edge.
+ *
+ * \verbatim im.ProcessSharp(src_image: imImage, dst_image: imImage, amount: number, threshold: number) [in Lua 5] \endverbatim
+ * \verbatim im.ProcessSharpNew(image: imImage, amount: number, threshold: number) -> new_image: imImage [in Lua 5] \endverbatim
+ * \ingroup convolve */
+int imProcessSharpKernel(const imImage* src_image, const imImage* kernel, imImage* dst_image, float amount, float threshold);
+
#if defined(__cplusplus)
}
diff --git a/include/im_process_pon.h b/include/im_process_pon.h
index bf09a71..0611cc6 100644
--- a/include/im_process_pon.h
+++ b/include/im_process_pon.h
@@ -22,14 +22,13 @@ extern "C" {
* See \ref im_process_pon.h
* \ingroup process */
-/** Unary Arithmetic Operations.
+/** Unary Arithmetic Operations. \n
* Inverse and log may lead to math exceptions.
* \ingroup arithm */
enum imUnaryOp {
IM_UN_EQL, /**< equal = a */
IM_UN_ABS, /**< abssolute = |a| */
IM_UN_LESS, /**< less = -a */
- IM_UN_INC, /**< increment += a */
IM_UN_INV, /**< invert = 1/a (#) */
IM_UN_SQR, /**< square = a*a */
IM_UN_SQRT, /**< square root = a^(1/2) */
@@ -42,15 +41,22 @@ enum imUnaryOp {
};
/** Apply an arithmetic unary operation. \n
- * Can be done in place, images must match size, does not need to match type.
+ * Can be done in place, images must match size. \n
+ * Destiny image can be several types depending on source: \n
+ * \li byte -> byte, ushort, int, float
+ * \li ushort -> byte, ushort, int, float
+ * \li int -> byte, ushort, int, float
+ * \li float -> float
+ * \li complex -> complex
+ * If destiny is byte, then the result is cropped to 0-255.
*
* \verbatim im.ProcessUnArithmeticOp(src_image: imImage, dst_image: imImage, op: number) [in Lua 5] \endverbatim
* \verbatim im.ProcessUnArithmeticOpNew(image: imImage, op: number) -> new_image: imImage [in Lua 5] \endverbatim
* \ingroup arithm */
void imProcessUnArithmeticOp(const imImage* src_image, imImage* dst_image, int op);
-/** Binary Arithmetic Operations.
- * Inverse and log may lead to math exceptions.
+/** Binary Arithmetic Operations. \n
+ * Divide may lead to math exceptions.
* \ingroup arithm */
enum imBinaryOp {
IM_BIN_ADD, /**< add = a+b */
@@ -72,6 +78,7 @@ enum imBinaryOp {
* \li float -> float
* \li complex -> complex
* One exception is that you can combine complex with float resulting complex.
+ * If destiny is byte, then the result is cropped to 0-255.
*
* \verbatim im.ProcessArithmeticOp(src_image1: imImage, src_image2: imImage, dst_image: imImage, op: number) [in Lua 5] \endverbatim
* \verbatim im.ProcessArithmeticOpNew(image1: imImage, image2: imImage, op: number) -> new_image: imImage [in Lua 5] \endverbatim
@@ -88,6 +95,7 @@ void imProcessArithmeticOp(const imImage* src_image1, const imImage* src_image2,
* \li float -> float
* \li complex -> complex
* The constant value is type casted to an apropriate type before the operation.
+ * If destiny is byte, then the result is cropped to 0-255.
*
* \verbatim im.ProcessArithmeticConstOp(src_image: imImage, src_const: number, dst_image: imImage, op: number) [in Lua 5] \endverbatim
* \verbatim im.ProcessArithmeticConstOpNew(image: imImage, src_const: number, op: number) -> new_image: imImage [in Lua 5] \endverbatim
@@ -523,7 +531,7 @@ enum imToneGamut {
* Supports all data types except IM_CFLOAT. \n
* The linear operation do a special convertion when min > 0 and max < 1, it forces min=0 and max=1. \n
* IM_BYTE images have min=0 and max=255 always. \n
- * Can be done in place. When there is no extra params use NULL.
+ * Can be done in place. When there is no extra params, can use NULL.
*
* \verbatim im.ProcessToneGamut(src_image: imImage, dst_image: imImage, op: number, param: table of number) [in Lua 5] \endverbatim
* \verbatim im.ProcessToneGamutNew(src_image: imImage, op: number, param: table of number) -> new_image: imImage [in Lua 5] \endverbatim