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. --- src/lua5/im_process.lua | 3 +++ src/lua5/imlua_process.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) (limited to 'src/lua5') diff --git a/src/lua5/im_process.lua b/src/lua5/im_process.lua index eb9cae6..d74c6b1 100644 --- a/src/lua5/im_process.lua +++ b/src/lua5/im_process.lua @@ -243,6 +243,9 @@ OneSourceOneDest("ProcessZeroCrossing") OneSourceOneDest("ProcessCanny") OneSourceOneDest("ProcessUnArithmeticOp") TwoSourcesOneDest("ProcessArithmeticOp") +OneSourceOneDest("ProcessUnsharp") +OneSourceOneDest("ProcessSharp") +TwoSourcesOneDest("ProcessSharpKernel") function im.ProcessArithmeticConstOpNew (src_image, src_const, op) local dst_image = im.ImageCreateBased(src_image) diff --git a/src/lua5/imlua_process.c b/src/lua5/imlua_process.c index fa6dc89..863c1d6 100644 --- a/src/lua5/imlua_process.c +++ b/src/lua5/imlua_process.c @@ -2,7 +2,7 @@ * \brief IM Lua 5 Binding * * See Copyright Notice in im_lib.h - * $Id: imlua_process.c,v 1.7 2009/09/28 20:19:09 scuri Exp $ + * $Id: imlua_process.c,v 1.8 2009/10/01 02:56:58 scuri Exp $ */ #include @@ -1474,6 +1474,56 @@ static int imluaProcessCanny (lua_State *L) return 0; } +/*****************************************************************************\ + im.ProcessUnsharp +\*****************************************************************************/ +static int imluaProcessUnsharp(lua_State *L) +{ + imImage *src_image = imlua_checkimage(L, 1); + imImage *dst_image = imlua_checkimage(L, 2); + float p1 = (float)luaL_checknumber(L, 3); + float p2 = (float)luaL_checknumber(L, 4); + float p3 = (float)luaL_checknumber(L, 5); + + imlua_match(L, src_image, dst_image); + + imProcessUnsharp(src_image, dst_image, p1, p2, p3); + return 0; +} + +/*****************************************************************************\ + im.ProcessSharp +\*****************************************************************************/ +static int imluaProcessSharp(lua_State *L) +{ + imImage *src_image = imlua_checkimage(L, 1); + imImage *dst_image = imlua_checkimage(L, 2); + float p1 = (float)luaL_checknumber(L, 3); + float p2 = (float)luaL_checknumber(L, 4); + + imlua_match(L, src_image, dst_image); + + imProcessSharp(src_image, dst_image, p1, p2); + return 0; +} + +/*****************************************************************************\ + im.ProcessSharpKernel +\*****************************************************************************/ +static int imluaProcessSharpKernel(lua_State *L) +{ + imImage *src_image = imlua_checkimage(L, 1); + imImage *kernel = imlua_checkimage(L, 2); + imImage *dst_image = imlua_checkimage(L, 3); + float p1 = (float)luaL_checknumber(L, 4); + float p2 = (float)luaL_checknumber(L, 5); + + imlua_match(L, src_image, dst_image); + + imProcessSharpKernel(src_image, kernel, dst_image, p1, p2); + return 0; +} + /*****************************************************************************\ im.GaussianStdDev2Repetitions \*****************************************************************************/ @@ -2927,6 +2977,9 @@ static const luaL_reg improcess_lib[] = { {"ProcessSplineEdgeConvolve", imluaProcessSplineEdgeConvolve}, {"ProcessZeroCrossing", imluaProcessZeroCrossing}, {"ProcessCanny", imluaProcessCanny}, + {"ProcessUnsharp", imluaProcessUnsharp}, + {"ProcessSharp", imluaProcessSharp}, + {"ProcessSharpKernel", imluaProcessSharpKernel}, {"GaussianKernelSize2StdDev", imluaGaussianKernelSize2StdDev}, {"GaussianStdDev2KernelSize", imluaGaussianStdDev2KernelSize}, @@ -3013,7 +3066,6 @@ static const imlua_constant im_process_constants[] = { { "UN_EQL", IM_UN_EQL, NULL }, { "UN_ABS", IM_UN_ABS, NULL }, { "UN_LESS", IM_UN_LESS, NULL }, - { "UN_INC", IM_UN_INC, NULL }, { "UN_INV", IM_UN_INV, NULL }, { "UN_SQR", IM_UN_SQR, NULL }, { "UN_SQRT", IM_UN_SQRT, NULL }, -- cgit v1.2.3