mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-20 19:43:01 +00:00
fixed for offsetted regions. Do thresholding as part of find_max_blob().
2005-08-08 Sven Neumann <sven@gimp.org> * app/base/siox.c (find_max_blob): fixed for offsetted regions. Do thresholding as part of find_max_blob().
This commit is contained in:
parent
eb6268e53b
commit
3f9144e534
|
@ -1,6 +1,7 @@
|
||||||
2005-08-08 Sven Neumann <sven@gimp.org>
|
2005-08-08 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/base/siox.c (find_max_blob): fixed for offsetted regions.
|
* app/base/siox.c (find_max_blob): fixed for offsetted regions.
|
||||||
|
Do thresholding as part of find_max_blob().
|
||||||
|
|
||||||
2005-08-08 Michael Natterer <mitch@gimp.org>
|
2005-08-08 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
|
|
@ -522,37 +522,6 @@ create_signature (lab *input,
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
threshold_mask (TileManager *mask,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
gint width,
|
|
||||||
gint height)
|
|
||||||
{
|
|
||||||
PixelRegion region;
|
|
||||||
gpointer pr;
|
|
||||||
gint row, col;
|
|
||||||
|
|
||||||
pixel_region_init (®ion, mask, x, y, width, height, TRUE);
|
|
||||||
|
|
||||||
for (pr = pixel_regions_register (1, ®ion);
|
|
||||||
pr != NULL;
|
|
||||||
pr = pixel_regions_process (pr))
|
|
||||||
{
|
|
||||||
guchar *data = region.data;
|
|
||||||
|
|
||||||
for (row = 0; row < region.h; row++)
|
|
||||||
{
|
|
||||||
guchar *d = data;
|
|
||||||
|
|
||||||
for (col = 0; col < region.w; col++, d++)
|
|
||||||
*d = (*d & 0x80) ? 255 : 0;
|
|
||||||
|
|
||||||
data += region.rowstride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
smooth_mask (TileManager *mask,
|
smooth_mask (TileManager *mask,
|
||||||
gint x,
|
gint x,
|
||||||
|
@ -609,8 +578,8 @@ find_max_blob (TileManager *mask,
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
gint row, col;
|
gint row, col;
|
||||||
gint curlabel = 1;
|
gint curlabel = 1;
|
||||||
|
gint maxblob = 1;
|
||||||
gint maxregion = 0;
|
gint maxregion = 0;
|
||||||
gint maxblob = 0;
|
|
||||||
|
|
||||||
pixel_region_init (®ion, mask, x, y, width, height, FALSE);
|
pixel_region_init (®ion, mask, x, y, width, height, FALSE);
|
||||||
|
|
||||||
|
@ -705,8 +674,7 @@ find_max_blob (TileManager *mask,
|
||||||
|
|
||||||
for (col = 0; col < region.w; col++, d++, i++)
|
for (col = 0; col < region.w; col++, d++, i++)
|
||||||
{
|
{
|
||||||
if (labelfield[i] != 0 && labelfield[i] != maxblob)
|
*d = (labelfield[i] == maxblob) ? 255 : 0;
|
||||||
*d = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data += region.rowstride;
|
data += region.rowstride;
|
||||||
|
@ -959,10 +927,10 @@ siox_foreground_extract (TileManager *pixels,
|
||||||
|
|
||||||
siox_progress_update (progress_callback, progress_data, 0.9);
|
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);
|
||||||
|
|
||||||
/* Now erode, to make sure only "strongly connected components"
|
/* erode, to make sure only "strongly connected components"
|
||||||
* keep being connected
|
* keep being connected
|
||||||
*/
|
*/
|
||||||
erode_mask (mask, x, y, width, height);
|
erode_mask (mask, x, y, width, height);
|
||||||
|
@ -974,13 +942,10 @@ siox_foreground_extract (TileManager *pixels,
|
||||||
for (i = 0; i < smoothness; i++)
|
for (i = 0; i < smoothness; i++)
|
||||||
smooth_mask (mask, x, y, width, height);
|
smooth_mask (mask, x, y, width, height);
|
||||||
|
|
||||||
/* Threshold the values */
|
|
||||||
threshold_mask (mask, x, y, width, height);
|
|
||||||
|
|
||||||
/* search the biggest connected component again to kill jitter */
|
/* search the biggest connected component again to kill jitter */
|
||||||
find_max_blob (mask, x, y, width, height);
|
find_max_blob (mask, x, y, width, height);
|
||||||
|
|
||||||
/* Now dilate, to fill up boundary pixels killed by erode */
|
/* 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);
|
siox_progress_update (progress_callback, progress_data, 1.0);
|
||||||
|
|
Loading…
Reference in a new issue