[Gegl-developer] Proposition : GeglInterpolator

Geert Jordaens geert.jordaens at telenet.be
Wed Oct 18 11:27:20 PDT 2006


What I tried to do with the gegl_interpolator was in fact what gimp is 
doing in gimpdrawable-transform,
Gimp only downsamples in the scale-funcs not during the transformation .
I'm not sure if it is possible to corectly downsample during transformation.

So the resampler should use a transformation matrix, and take source 
coördinates.
instead of  :

  matrix3_copy (inverse, matrix);
  matrix3_invert (inverse);

  fu = du = inverse[0][0] * dest->x + inverse[0][1] * dest->y + inverse[0][2] - src->x;
  fv = dv = inverse[1][0] * dest->x + inverse[1][1] * dest->y + inverse[1][2] - src->y;

  for (dest_ptr = dest_buf, y = 0; y < dest->height; y++)
    {
      for (x = 0; x < dest->width; x++)
        {
          gegl_interpolator_get (interpolator, fu,  fv, dest_buf);
          fu += inverse [0][0];
          fv += inverse [1][0];
        }
      du += inverse [0][1];
      dv += inverse [1][1];
      fu = du;
      fv = dv;
      ...
    }

The transformed coordinates should be calculated within the resampler.
  gegl_resampler_set_matrix(resampler, matrix);

  for (y = 0; y < dest->height; y++)
    {
      for (x = 0; x < dest->width; x++)
        { 
           gegl_resampler_get (resampler, x,  y, dest_buf);             
        }
      ...
    }

The gegl_resampler_get should then calculate the number of transformed 
coordinates needed by the
resampling method (lanczos/bicubic/bilinear/nearest) as in 
gimpdrawable-transform.

ca= cos a
sa = sin a
.   = don't touch

gegl_resampler_set_matrix_identity()
    | 1    0     0 |
    | 0    1     0 |
    | 0    0     1 | 
gegl_resampler_set_scale(x, y) 
    | *sy  .     0 |
    | .    *sy   0 |
    | .    .     1 |
gegl_resampler_set_translscale(tx, ty)
    | .    .     0 |
    | .    .     0 |
    | tx   ty    1 |

gegl_resampler_set_rotate(a)
    | *ca  *sa   0 |
    | *-sa *ca   0 |
    | .    .     1 |

gegl_resampler_set_matrix(a,b,c,d,e,f )
    | a    d    0 |
    | b    e    0 |
    | c    f    1 |

Geert







More information about the Gegl-developer mailing list