Commit a0265244 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/base/siox.[ch] pass progress_callback and progress_data to

2005-07-29  Sven Neumann  <sven@gimp.org>

	* app/base/siox.[ch]
	* app/core/gimpdrawable-foreground-extract.c: pass progress_callback
	and progress_data to siox_foreground_extract().
parent 9dfb56a4
2005-07-29 Sven Neumann <sven@gimp.org>
* app/base/siox.[ch]
* app/core/gimpdrawable-foreground-extract.c: pass progress_callback
and progress_data to siox_foreground_extract().
2005-07-29 Sven Neumann <sven@gimp.org>
* app/base/siox.c (add_to_list): keep a tail pointer. Speeds up
the benchmark by about 50%.
2005-07-29 Sven Neumann <sven@gimp.org> 2005-07-29 Sven Neumann <sven@gimp.org>
* app/core/gimpdrawable-foreground-extract.[ch]: added a progress * app/core/gimpdrawable-foreground-extract.[ch]: added a progress
......
...@@ -763,6 +763,14 @@ get_clustersize (const gfloat limits[SIOX_DIMS]) ...@@ -763,6 +763,14 @@ get_clustersize (const gfloat limits[SIOX_DIMS])
return sum; return sum;
} }
static inline void
siox_progress_update (SioxProgressFunc progress_callback,
gpointer progress_data,
gdouble value)
{
if (progress_data)
progress_callback (progress_data, value);
}
/** /**
* siox_foreground_extract: * siox_foreground_extract:
...@@ -780,13 +788,15 @@ get_clustersize (const gfloat limits[SIOX_DIMS]) ...@@ -780,13 +788,15 @@ get_clustersize (const gfloat limits[SIOX_DIMS])
* Writes the resulting segmentation into @mask. * Writes the resulting segmentation into @mask.
*/ */
void void
siox_foreground_extract (TileManager *pixels, siox_foreground_extract (TileManager *pixels,
const guchar *colormap, const guchar *colormap,
gint offset_x, gint offset_x,
gint offset_y, gint offset_y,
TileManager *mask, TileManager *mask,
const gfloat limits[SIOX_DIMS], const gfloat limits[SIOX_DIMS],
gint smoothness) gint smoothness,
SioxProgressFunc progress_callback,
gpointer progress_data)
{ {
PixelRegion srcPR; PixelRegion srcPR;
PixelRegion mapPR; PixelRegion mapPR;
...@@ -808,6 +818,7 @@ siox_foreground_extract (TileManager *pixels, ...@@ -808,6 +818,7 @@ siox_foreground_extract (TileManager *pixels,
g_return_if_fail (pixels != NULL); g_return_if_fail (pixels != NULL);
g_return_if_fail (mask != NULL && tile_manager_bpp (mask) == 1); g_return_if_fail (mask != NULL && tile_manager_bpp (mask) == 1);
g_return_if_fail (progress_data == NULL || progress_callback != NULL);
cpercep_init (); cpercep_init ();
...@@ -826,6 +837,8 @@ siox_foreground_extract (TileManager *pixels, ...@@ -826,6 +837,8 @@ siox_foreground_extract (TileManager *pixels,
if (! intersect) if (! intersect)
return; return;
siox_progress_update (progress_callback, progress_data, 0.0);
/* count given foreground and background pixels */ /* count given foreground and background pixels */
pixel_region_init (&mapPR, mask, x, y, width, height, FALSE); pixel_region_init (&mapPR, mask, x, y, width, height, FALSE);
...@@ -857,6 +870,8 @@ siox_foreground_extract (TileManager *pixels, ...@@ -857,6 +870,8 @@ siox_foreground_extract (TileManager *pixels,
i = 0; i = 0;
j = 0; j = 0;
siox_progress_update (progress_callback, progress_data, 0.1);
bpp = tile_manager_bpp (pixels); bpp = tile_manager_bpp (pixels);
/* create inputs for colorsignatures */ /* create inputs for colorsignatures */
...@@ -895,6 +910,8 @@ siox_foreground_extract (TileManager *pixels, ...@@ -895,6 +910,8 @@ siox_foreground_extract (TileManager *pixels,
} }
} }
siox_progress_update (progress_callback, progress_data, 0.2);
/* Create color signature for the background */ /* Create color signature for the background */
bgsig = create_signature (surebg, surebgcount, limits, &bgsiglen); bgsig = create_signature (surebg, surebgcount, limits, &bgsiglen);
g_free (surebg); g_free (surebg);
...@@ -905,10 +922,14 @@ siox_foreground_extract (TileManager *pixels, ...@@ -905,10 +922,14 @@ siox_foreground_extract (TileManager *pixels,
return; return;
} }
siox_progress_update (progress_callback, progress_data, 0.3);
/* Create color signature for the foreground */ /* Create color signature for the foreground */
fgsig = create_signature (surefg, surefgcount, limits, &fgsiglen); fgsig = create_signature (surefg, surefgcount, limits, &fgsiglen);
g_free (surefg); g_free (surefg);
siox_progress_update (progress_callback, progress_data, 0.4);
/* Classify - the slow way....Better: Tree traversation */ /* Classify - the slow way....Better: Tree traversation */
pixel_region_init (&srcPR, pixels, pixel_region_init (&srcPR, pixels,
x - offset_x, y - offset_y, width, height, FALSE); x - offset_x, y - offset_y, width, height, FALSE);
...@@ -980,6 +1001,8 @@ siox_foreground_extract (TileManager *pixels, ...@@ -980,6 +1001,8 @@ siox_foreground_extract (TileManager *pixels,
g_free (fgsig); g_free (fgsig);
g_free (bgsig); g_free (bgsig);
siox_progress_update (progress_callback, progress_data, 0.9);
/* Smooth a bit for error killing */ /* Smooth a bit for error killing */
smooth_mask (mask, x, y, width, height); smooth_mask (mask, x, y, width, height);
...@@ -1003,4 +1026,6 @@ siox_foreground_extract (TileManager *pixels, ...@@ -1003,4 +1026,6 @@ siox_foreground_extract (TileManager *pixels,
/* Now dilate, to fill up boundary pixels killed by erode */ /* Now dilate, to fill up boundary pixels killed by erode */
dilate_mask (mask, x, y, width, height); dilate_mask (mask, x, y, width, height);
siox_progress_update (progress_callback, progress_data, 1.0);
} }
...@@ -41,13 +41,19 @@ ...@@ -41,13 +41,19 @@
#define SIOX_DIMS 3 #define SIOX_DIMS 3
void siox_foreground_extract (TileManager *pixels, typedef void (* SioxProgressFunc) (gpointer progress_data,
const guchar *colormap, gdouble fraction);
gint offset_x,
gint offset_y,
TileManager *map, void siox_foreground_extract (TileManager *pixels,
const gfloat limits[SIOX_DIMS], const guchar *colormap,
gint smoothness); gint offset_x,
gint offset_y,
TileManager *map,
const gfloat limits[SIOX_DIMS],
gint smoothness,
SioxProgressFunc progress_callback,
gpointer progress_data);
#endif /* __SIOX_H__ */ #endif /* __SIOX_H__ */
...@@ -71,9 +71,12 @@ gimp_drawable_foreground_extract (GimpDrawable *drawable, ...@@ -71,9 +71,12 @@ gimp_drawable_foreground_extract (GimpDrawable *drawable,
case GIMP_FOREGROUND_EXTRACT_SIOX: case GIMP_FOREGROUND_EXTRACT_SIOX:
{ {
const gfloat limits[SIOX_DIMS] = { 0.66, 1.25, 2.5 }; const gfloat limits[SIOX_DIMS] = { 0.66, 1.25, 2.5 };
siox_foreground_extract (gimp_drawable_data (drawable), colormap, x, y, siox_foreground_extract (gimp_drawable_data (drawable), colormap, x, y,
gimp_drawable_data (mask), gimp_drawable_data (mask),
limits, 3); limits, 3,
(SioxProgressFunc) gimp_progress_set_value,
progress);
} }
break; break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment