summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html/en/history.html5
-rw-r--r--include/im_process_ana.h11
-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
6 files changed, 29 insertions, 18 deletions
diff --git a/html/en/history.html b/html/en/history.html
index cec5209..afff43e 100644
--- a/html/en/history.html
+++ b/html/en/history.html
@@ -12,7 +12,7 @@
<h1>History of Changes</h1>
<h3 dir="ltr">
- CVS (10/Set/2009)</h3>
+ CVS (28/Set/2009)</h3>
<ul>
<li><span style="color: #0000FF">New:</span> function <strong>
imImageGetOpenGLData</strong>.</li>
@@ -35,6 +35,9 @@
style="color: #000000"> <strong>imImageCreateBased</strong> and
<strong>imConvertColorSpace</strong> now also
consider the alpha plane.</span></span></li>
+ <li><span style="color: #008000">Changed: </span><strong>imProcessPrune</strong>
+ renamed to <strong>imProcessRemoveByArea</strong>, and added a new
+ parameter to select inside or outside the interval.</li>
<li><span style="color: #008000"><span style="color: #ff0000">Fixed:</span><span
style="color: #000000"> PNG attribute TransparencyIndex. new PNG
attribute TransparencyMap. TransparentColor renamed to
diff --git a/include/im_process_ana.h b/include/im_process_ana.h
index 2853e02..e7a897a 100644
--- a/include/im_process_ana.h
+++ b/include/im_process_ana.h
@@ -195,14 +195,15 @@ void imAnalyzeMeasurePerimeter(const imImage* image, float* perim, int region_co
* \ingroup analyze */
void imProcessPerimeterLine(const imImage* src_image, imImage* dst_image);
-/** Eliminates regions that have size outside the given interval. \n
+/** Eliminates regions that have area size outside or inside the given interval. \n
* Source and destiny are a binary images. Regions can be 4 connected or 8 connected. \n
- * Can be done in-place. end_size can be zero to ignore big objects.
+ * Can be done in-place. end_size can be zero to indicate no upper limit or an area with width*height size. \n
+ * When searching inside the region the limits are inclusive (<= size >=), when searching outside the limits are exclusive (> size <).
*
- * \verbatim im.ProcessPrune(src_image: imImage, dst_image: imImage, connect: number, start_size: number, end_size: number) [in Lua 5] \endverbatim
- * \verbatim im.ProcessPruneNew(image: imImage, connect: number, start_size: number, end_size: number) -> new_image: imImage [in Lua 5] \endverbatim
+ * \verbatim im.ProcessRemoveByArea(src_image: imImage, dst_image: imImage, connect: number, start_size: number, end_size: number, inside: boolean) [in Lua 5] \endverbatim
+ * \verbatim im.ProcessRemoveByAreaNew(image: imImage, connect: number, start_size: number, end_size: number, inside: boolean) -> new_image: imImage [in Lua 5] \endverbatim
* \ingroup analyze */
-void imProcessPrune(const imImage* src_image, imImage* dst_image, int connect, int start_size, int end_size);
+void imProcessRemoveByArea(const imImage* src_image, imImage* dst_image, int connect, int start_size, int end_size, int inside);
/** Fill holes inside white regions. \n
* Source and destiny are a binary images. Regions can be 4 connected or 8 connected. \n
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;