Beispiel #1
0
static gboolean
gegl_affine_matrix3_allow_fast_translate (GeglMatrix3 *matrix)
{
  if (! GEGL_FLOAT_EQUAL (matrix->coeff[0][2], (gint) matrix->coeff[0][2]) ||
      ! GEGL_FLOAT_EQUAL (matrix->coeff[1][2], (gint) matrix->coeff[1][2]))
    return FALSE;
  return gegl_matrix3_is_translate (matrix);
}
Beispiel #2
0
static gboolean
gegl_affine_matrix3_allow_fast_reflect_y (GeglMatrix3 *matrix)
{
  GeglMatrix3 copy;

  if (! GEGL_FLOAT_EQUAL (matrix->coeff[0][0], -1.0))
    return FALSE;
  gegl_matrix3_copy_into (&copy, matrix);
  copy.coeff[0][0] = 1.;
  return gegl_affine_matrix3_allow_fast_translate (&copy);
}
Beispiel #3
0
static gboolean
process (GeglOperation       *operation,
         GeglBuffer          *input,
         GeglBuffer          *output,
         const GeglRectangle *result,
         gint                 level)
{
  GeglProperties         *o = GEGL_PROPERTIES (operation);
  GeglBufferIterator *iter;
  GeglBuffer         *dest1;
  GeglBuffer         *dest2;
  GeglSampler        *sampler1;
  GeglSampler        *sampler2;
  gdouble             ramp;
  gint                x;
  gint                y;
  gfloat              tot_pixels = result->width * result->height;
  gfloat              pixels = 0;

  grey_blur_buffer (input, o->mask_radius, &dest1, &dest2);

  sampler1 = gegl_buffer_sampler_new_at_level (dest1,
                                               babl_format ("Y' float"),
                                               GEGL_SAMPLER_LINEAR,
                                               level);

  sampler2 = gegl_buffer_sampler_new_at_level (dest2,
                                               babl_format ("Y' float"),
                                               GEGL_SAMPLER_LINEAR,
                                               level);

  ramp = compute_ramp (sampler1, sampler2, result, o->pct_black);

  iter = gegl_buffer_iterator_new (output, result, 0,
                                   babl_format ("Y'CbCrA float"),
                                   GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE);
  gegl_buffer_iterator_add (iter, input, result, 0,
                            babl_format ("Y'CbCrA float"),
                            GEGL_ACCESS_READ, GEGL_ABYSS_NONE);


  gegl_operation_progress (operation, 0.0, "");

  while (gegl_buffer_iterator_next (iter))
    {
      gfloat *out_pixel = iter->data[0];
      gfloat *in_pixel  = iter->data[1];

      for (y = iter->roi[0].y; y < iter->roi[0].y + iter->roi[0].height; ++y)
      {
        for (x = iter->roi[0].x; x < iter->roi[0].x + iter->roi[0].width; ++x)
          {
            gfloat  pixel1;
            gfloat  pixel2;
            gdouble mult = 0.0;
            gdouble diff;

            gegl_sampler_get (sampler1, x, y,
                              NULL, &pixel1,
                              GEGL_ABYSS_NONE);

            gegl_sampler_get (sampler2, x, y,
                              NULL, &pixel2,
                              GEGL_ABYSS_NONE);

            if (pixel2 != 0)
              {
                diff = (gdouble) pixel1 / (gdouble) pixel2;
                if (diff < THRESHOLD)
                  {
                    if (GEGL_FLOAT_EQUAL (ramp, 0.0))
                      mult = 0.0;
                    else
                      mult = (ramp - MIN (ramp, (THRESHOLD - diff))) / ramp;
                  }
                else
                  mult = 1.0;
              }

            out_pixel[0] = CLAMP (pixel1 * mult, 0.0, 1.0);
            out_pixel[1] = in_pixel[1];
            out_pixel[2] = in_pixel[2];
            out_pixel[3] = in_pixel[3];

            out_pixel += 4;
            in_pixel  += 4;

          }
        pixels += iter->roi[0].width;
        gegl_operation_progress (operation, pixels / tot_pixels, "");
      }
    }

  gegl_operation_progress (operation, 1.0, "");

  g_object_unref (sampler1);
  g_object_unref (sampler2);

  g_object_unref (dest1);
  g_object_unref (dest2);

  return TRUE;
}