summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorscuri <scuri>2009-09-28 20:18:52 +0000
committerscuri <scuri>2009-09-28 20:18:52 +0000
commitd2c116c0adc98b18124b6c3cbf2b839d5719444f (patch)
tree7aaf21298526da5fa1516d15782dc4c8ed1b6fc6 /src
parent9f84f624d3a6be89804a55ddea878f4cdaca6e77 (diff)
Changed: imProcessPrune renamed to imProcessRemoveByArea, and added a new parameter to select inside or outside the interval.
Diffstat (limited to 'src')
-rw-r--r--src/im_process.def2
-rw-r--r--src/lua5/im_process.lua2
-rw-r--r--src/lua5/imlua_process.c11
-rw-r--r--src/process/im_analyze.cpp16
4 files changed, 19 insertions, 12 deletions
diff --git a/src/im_process.def b/src/im_process.def
index b3e1a2b..fd3d5dd 100644
--- a/src/im_process.def
+++ b/src/im_process.def
@@ -121,7 +121,7 @@ EXPORTS
imAnalyzeMeasureHoles
imProcessPerimeterLine
imAnalyzeMeasurePerimeter
- imProcessPrune
+ imProcessRemoveByArea
imProcessFillHoles
imAnalyzeMeasurePerimArea
imProcessSliceThreshold
diff --git a/src/lua5/im_process.lua b/src/lua5/im_process.lua
index fbe9534..eb9cae6 100644
--- a/src/lua5/im_process.lua
+++ b/src/lua5/im_process.lua
@@ -131,7 +131,7 @@ end
OneSourceOneDest("AnalyzeFindRegions", nil, nil, nil, im.USHORT)
OneSourceOneDest("ProcessPerimeterLine")
-OneSourceOneDest("ProcessPrune")
+OneSourceOneDest("ProcessRemoveByArea")
OneSourceOneDest("ProcessFillHoles")
OneSourceOneDest("ProcessHoughLines", 180, hough_height, im.GRAY, im.INT)
OneSourceOneDest("ProcessHoughLinesDraw")
diff --git a/src/lua5/imlua_process.c b/src/lua5/imlua_process.c
index 1c0dfc8..fa6dc89 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.6 2009/08/12 04:09:17 scuri Exp $
+ * $Id: imlua_process.c,v 1.7 2009/09/28 20:19:09 scuri Exp $
*/
#include <memory.h>
@@ -441,21 +441,22 @@ static int imluaProcessPerimeterLine (lua_State *L)
}
/*****************************************************************************\
- im.ProcessPrune(src_image, dst_image, connect, start_size, end_size)
+ im.ProcessRemoveByArea(src_image, dst_image, connect, start_size, end_size, inside)
\*****************************************************************************/
-static int imluaProcessPrune (lua_State *L)
+static int imluaProcessRemoveByArea (lua_State *L)
{
imImage* src_image = imlua_checkimage(L, 1);
imImage* dst_image = imlua_checkimage(L, 2);
int connect = luaL_checkint(L, 3);
int start_size = luaL_checkint(L, 4);
int end_size = luaL_checkint(L, 5);
+ int inside = lua_toboolean(L, 6);
imlua_checkcolorspace(L, 1, src_image, IM_BINARY);
imlua_match(L, src_image, dst_image);
luaL_argcheck(L, (connect == 4 || connect == 8), 3, "invalid connect value, must be 4 or 8");
- imProcessPrune(src_image, dst_image, connect, start_size, end_size);
+ imProcessRemoveByArea(src_image, dst_image, connect, start_size, end_size, inside);
return 0;
}
@@ -2861,7 +2862,7 @@ static const luaL_reg improcess_lib[] = {
{"AnalyzeMeasureHoles", imluaAnalyzeMeasureHoles},
{"ProcessPerimeterLine", imluaProcessPerimeterLine},
- {"ProcessPrune", imluaProcessPrune},
+ {"ProcessRemoveByArea", imluaProcessRemoveByArea},
{"ProcessFillHoles", imluaProcessFillHoles},
{"ProcessHoughLines", imluaProcessHoughLines},
diff --git a/src/process/im_analyze.cpp b/src/process/im_analyze.cpp
index 50bcbcd..6fa9405 100644
--- a/src/process/im_analyze.cpp
+++ b/src/process/im_analyze.cpp
@@ -2,7 +2,7 @@
* \brief Image Analysis
*
* See Copyright Notice in im_lib.h
- * $Id: im_analyze.cpp,v 1.1 2008/10/17 06:16:33 scuri Exp $
+ * $Id: im_analyze.cpp,v 1.2 2009/09/28 20:19:09 scuri Exp $
*/
@@ -1186,7 +1186,7 @@ void imAnalyzeMeasurePerimArea(const imImage* image, float* area_data)
}
}
-void imProcessPrune(const imImage* image, imImage* NewImage, int connect, int start_size, int end_size)
+void imProcessRemoveByArea(const imImage* image, imImage* NewImage, int connect, int start_size, int end_size, int inside)
{
imImage *region_image = imImageCreate(image->width, image->height, IM_GRAY, IM_USHORT);
if (!region_image)
@@ -1200,6 +1200,12 @@ void imProcessPrune(const imImage* image, imImage* NewImage, int connect, int st
return;
}
+ if (end_size == 0)
+ end_size = image->width*image->height;
+
+ int outside=0;
+ if (!inside) outside = 1;
+
int* area_data = (int*)malloc(region_count*sizeof(int));
imAnalyzeMeasureArea(region_image, area_data, region_count);
@@ -1211,10 +1217,10 @@ void imProcessPrune(const imImage* image, imImage* NewImage, int connect, int st
if (*region_data)
{
int area = area_data[(*region_data) - 1];
- if (area < start_size || (end_size && area > end_size))
- *img_data = 0;
+ if (area < start_size || area > end_size)
+ *img_data = (imbyte)outside;
else
- *img_data = 1;
+ *img_data = (imbyte)inside;
}
else
*img_data = 0;