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().
This commit is contained in:
Sven Neumann 2005-07-29 16:09:16 +00:00 committed by Sven Neumann
parent 9dfb56a435
commit a026524412
4 changed files with 60 additions and 15 deletions

View File

@ -1,3 +1,14 @@
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>
* app/core/gimpdrawable-foreground-extract.[ch]: added a progress

View File

@ -763,6 +763,14 @@ get_clustersize (const gfloat limits[SIOX_DIMS])
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:
@ -780,13 +788,15 @@ get_clustersize (const gfloat limits[SIOX_DIMS])
* Writes the resulting segmentation into @mask.
*/
void
siox_foreground_extract (TileManager *pixels,
const guchar *colormap,
gint offset_x,
gint offset_y,
TileManager *mask,
const gfloat limits[SIOX_DIMS],
gint smoothness)
siox_foreground_extract (TileManager *pixels,
const guchar *colormap,
gint offset_x,
gint offset_y,
TileManager *mask,
const gfloat limits[SIOX_DIMS],
gint smoothness,
SioxProgressFunc progress_callback,
gpointer progress_data)
{
PixelRegion srcPR;
PixelRegion mapPR;
@ -808,6 +818,7 @@ siox_foreground_extract (TileManager *pixels,
g_return_if_fail (pixels != NULL);
g_return_if_fail (mask != NULL && tile_manager_bpp (mask) == 1);
g_return_if_fail (progress_data == NULL || progress_callback != NULL);
cpercep_init ();
@ -826,6 +837,8 @@ siox_foreground_extract (TileManager *pixels,
if (! intersect)
return;
siox_progress_update (progress_callback, progress_data, 0.0);
/* count given foreground and background pixels */
pixel_region_init (&mapPR, mask, x, y, width, height, FALSE);
@ -857,6 +870,8 @@ siox_foreground_extract (TileManager *pixels,
i = 0;
j = 0;
siox_progress_update (progress_callback, progress_data, 0.1);
bpp = tile_manager_bpp (pixels);
/* create inputs for colorsignatures */
@ -895,6 +910,8 @@ siox_foreground_extract (TileManager *pixels,
}
}
siox_progress_update (progress_callback, progress_data, 0.2);
/* Create color signature for the background */
bgsig = create_signature (surebg, surebgcount, limits, &bgsiglen);
g_free (surebg);
@ -905,10 +922,14 @@ siox_foreground_extract (TileManager *pixels,
return;
}
siox_progress_update (progress_callback, progress_data, 0.3);
/* Create color signature for the foreground */
fgsig = create_signature (surefg, surefgcount, limits, &fgsiglen);
g_free (surefg);
siox_progress_update (progress_callback, progress_data, 0.4);
/* Classify - the slow way....Better: Tree traversation */
pixel_region_init (&srcPR, pixels,
x - offset_x, y - offset_y, width, height, FALSE);
@ -980,6 +1001,8 @@ siox_foreground_extract (TileManager *pixels,
g_free (fgsig);
g_free (bgsig);
siox_progress_update (progress_callback, progress_data, 0.9);
/* Smooth a bit for error killing */
smooth_mask (mask, x, y, width, height);
@ -1003,4 +1026,6 @@ siox_foreground_extract (TileManager *pixels,
/* Now dilate, to fill up boundary pixels killed by erode */
dilate_mask (mask, x, y, width, height);
siox_progress_update (progress_callback, progress_data, 1.0);
}

View File

@ -41,13 +41,19 @@
#define SIOX_DIMS 3
void siox_foreground_extract (TileManager *pixels,
const guchar *colormap,
gint offset_x,
gint offset_y,
TileManager *map,
const gfloat limits[SIOX_DIMS],
gint smoothness);
typedef void (* SioxProgressFunc) (gpointer progress_data,
gdouble fraction);
void siox_foreground_extract (TileManager *pixels,
const guchar *colormap,
gint offset_x,
gint offset_y,
TileManager *map,
const gfloat limits[SIOX_DIMS],
gint smoothness,
SioxProgressFunc progress_callback,
gpointer progress_data);
#endif /* __SIOX_H__ */

View File

@ -71,9 +71,12 @@ gimp_drawable_foreground_extract (GimpDrawable *drawable,
case GIMP_FOREGROUND_EXTRACT_SIOX:
{
const gfloat limits[SIOX_DIMS] = { 0.66, 1.25, 2.5 };
siox_foreground_extract (gimp_drawable_data (drawable), colormap, x, y,
gimp_drawable_data (mask),
limits, 3);
limits, 3,
(SioxProgressFunc) gimp_progress_set_value,
progress);
}
break;