for now, implement smooth_mask() by means of gaussian_blur_region().
2005-07-11 Sven Neumann <sven@gimp.org> * app/base/segmentator.c: for now, implement smooth_mask() by means of gaussian_blur_region().
This commit is contained in:
committed by
Sven Neumann
parent
5d7b80c776
commit
1aae154af7
135
app/base/siox.c
135
app/base/siox.c
@ -549,70 +549,6 @@ create_signature (lab *input,
|
||||
return rval;
|
||||
}
|
||||
|
||||
/* Smoothes the confidence matrix */
|
||||
static void
|
||||
smoothcm (float *cm,
|
||||
int xres,
|
||||
int yres,
|
||||
float f1,
|
||||
float f2,
|
||||
float f3)
|
||||
{
|
||||
int y, x, idx;
|
||||
|
||||
/* Smoothright */
|
||||
for (y = 0; y < yres; y++)
|
||||
{
|
||||
for (x = 0; x < xres - 2; x++)
|
||||
{
|
||||
idx = (y * xres) + x;
|
||||
cm[idx] =
|
||||
f1 * cm[idx] +
|
||||
f2 * cm[idx + 1] +
|
||||
f3 * cm[idx + 2];
|
||||
}
|
||||
}
|
||||
|
||||
/* Smoothleft */
|
||||
for (y = 0; y < yres; y++)
|
||||
{
|
||||
for (x = xres - 1; x >= 2; x--)
|
||||
{
|
||||
idx = (y * xres) + x;
|
||||
cm[idx] =
|
||||
f3 * cm[idx - 2] +
|
||||
f2 * cm[idx - 1] +
|
||||
f1 * cm[idx];
|
||||
}
|
||||
}
|
||||
|
||||
/* Smoothdown */
|
||||
for (y = 0; y < yres - 2; y++)
|
||||
{
|
||||
for (x = 0; x < xres; x++)
|
||||
{
|
||||
idx = (y * xres) + x;
|
||||
cm[idx] =
|
||||
f1 * cm[idx] +
|
||||
f2 * cm[((y + 1) * xres) + x] +
|
||||
f3 * cm[((y + 2) * xres) + x];
|
||||
}
|
||||
}
|
||||
|
||||
/* Smoothup */
|
||||
for (y = yres - 1; y >= 2; y--)
|
||||
{
|
||||
for (x = 0; x < xres; x++)
|
||||
{
|
||||
idx = (y * xres) + x;
|
||||
cm[idx] =
|
||||
f3 * cm[((y - 2) * xres) + x] +
|
||||
f2 * cm[((y - 1) * xres) + x] +
|
||||
f1 * cm[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
normalize_mask (TileManager *mask,
|
||||
gint x,
|
||||
@ -694,7 +630,12 @@ smooth_mask (TileManager *mask,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
/* TODO */
|
||||
PixelRegion region;
|
||||
|
||||
pixel_region_init (®ion, mask, x, y, width, height, TRUE);
|
||||
|
||||
/* inefficient */
|
||||
gaussian_blur_region (®ion, 1.0, 1.0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1210,6 +1151,70 @@ dilate2 (float *cm,
|
||||
}
|
||||
}
|
||||
|
||||
/* Smoothes the confidence matrix */
|
||||
static void
|
||||
smoothcm (float *cm,
|
||||
int xres,
|
||||
int yres,
|
||||
float f1,
|
||||
float f2,
|
||||
float f3)
|
||||
{
|
||||
int y, x, idx;
|
||||
|
||||
/* Smoothright */
|
||||
for (y = 0; y < yres; y++)
|
||||
{
|
||||
for (x = 0; x < xres - 2; x++)
|
||||
{
|
||||
idx = (y * xres) + x;
|
||||
cm[idx] =
|
||||
f1 * cm[idx] +
|
||||
f2 * cm[idx + 1] +
|
||||
f3 * cm[idx + 2];
|
||||
}
|
||||
}
|
||||
|
||||
/* Smoothleft */
|
||||
for (y = 0; y < yres; y++)
|
||||
{
|
||||
for (x = xres - 1; x >= 2; x--)
|
||||
{
|
||||
idx = (y * xres) + x;
|
||||
cm[idx] =
|
||||
f3 * cm[idx - 2] +
|
||||
f2 * cm[idx - 1] +
|
||||
f1 * cm[idx];
|
||||
}
|
||||
}
|
||||
|
||||
/* Smoothdown */
|
||||
for (y = 0; y < yres - 2; y++)
|
||||
{
|
||||
for (x = 0; x < xres; x++)
|
||||
{
|
||||
idx = (y * xres) + x;
|
||||
cm[idx] =
|
||||
f1 * cm[idx] +
|
||||
f2 * cm[((y + 1) * xres) + x] +
|
||||
f3 * cm[((y + 2) * xres) + x];
|
||||
}
|
||||
}
|
||||
|
||||
/* Smoothup */
|
||||
for (y = yres - 1; y >= 2; y--)
|
||||
{
|
||||
for (x = 0; x < xres; x++)
|
||||
{
|
||||
idx = (y * xres) + x;
|
||||
cm[idx] =
|
||||
f3 * cm[((y - 2) * xres) + x] +
|
||||
f2 * cm[((y - 1) * xres) + x] +
|
||||
f1 * cm[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* region growing */
|
||||
static void
|
||||
findmaxblob (float *cm,
|
||||
|
||||
Reference in New Issue
Block a user