diff options
author | scuri <scuri> | 2009-09-28 20:18:52 +0000 |
---|---|---|
committer | scuri <scuri> | 2009-09-28 20:18:52 +0000 |
commit | d2c116c0adc98b18124b6c3cbf2b839d5719444f (patch) | |
tree | 7aaf21298526da5fa1516d15782dc4c8ed1b6fc6 /src/process | |
parent | 9f84f624d3a6be89804a55ddea878f4cdaca6e77 (diff) |
Changed: imProcessPrune renamed to imProcessRemoveByArea, and added a new parameter to select inside or outside the interval.
Diffstat (limited to 'src/process')
-rw-r--r-- | src/process/im_analyze.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
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; |