Пример #1
0
static int Swirl(int width, int height, DT *src_map, DT *dst_map, 
                         float k, int counter, DTU Dummy, int order)
{
  float xl, yl;
  float xc = float(width/2.);
  float yc = float(height/2.);
         
  for (int y = 0; y < height; y++)
  {
    for (int x = 0; x < width; x++)
    {
      swirl_invtransf(x, y, &xl, &yl, k, xc, yc);
                   
      // if inside the original image broad area
      if (xl > 0.0 && yl > 0.0 && xl < width && yl < height)
      {
        if (order == 1)
          *dst_map = imBilinearInterpolation(width, height, src_map, xl, yl);
        else if (order == 3)
          *dst_map = imBicubicInterpolation(width, height, src_map, xl, yl, Dummy);
        else
          *dst_map = imZeroOrderInterpolation(width, height, src_map, xl, yl);
      }

      dst_map++;
    }

    if (!imCounterInc(counter))
      return 0;
  }

  return 1;
}
Пример #2
0
static int iResize(int src_width, int src_height, const DT *src_map, 
                         int dst_width, int dst_height, DT *dst_map, 
                         DTU Dummy, int order, int counter)
{
  float x_invfactor = float(src_width)/float(dst_width);
  float y_invfactor = float(src_height)/float(dst_height);

  IM_INT_PROCESSING;

#ifdef _OPENMP
#pragma omp parallel for if (IM_OMP_MINHEIGHT(dst_height))
#endif
  for (int y = 0; y < dst_height; y++)
  {
#ifdef _OPENMP
#pragma omp flush (processing)
#endif
    IM_BEGIN_PROCESSING;

    int line_offset = y*dst_width;

    for (int x = 0; x < dst_width; x++)
    {
      float xl, yl;
      iResizeInverse(x, y, &xl, &yl, x_invfactor, y_invfactor);
                   
      // if inside the original image
      if (xl > 0.0 && yl > 0.0 && xl < src_width && yl < src_height)
      {
        if (order == 1)
          dst_map[line_offset+x] = imBilinearInterpolation(src_width, src_height, src_map, xl, yl);
        else if (order == 3)
          dst_map[line_offset+x] = imBicubicInterpolation(src_width, src_height, src_map, xl, yl, Dummy);
        else
          dst_map[line_offset+x] = imZeroOrderInterpolation(src_width, src_height, src_map, xl, yl);
      }
    }

    IM_COUNT_PROCESSING;
#ifdef _OPENMP
#pragma omp flush (processing)
#endif
    IM_END_PROCESSING;
  }

  return processing;
}
Пример #3
0
static int Rotate(int src_width, int src_height, DT *src_map, 
                  int dst_width, int dst_height, DT *dst_map, 
                  double cos0, double sin0, int ref_x, int ref_y, int to_origin, 
                  int counter, DTU Dummy, int order)
{
  float xl, yl;
  float sx = float(ref_x);
  float sy = float(ref_y);
  float dx = sx;
  float dy = sy;
  if (to_origin)
  {
    dx = 0;
    dy = 0;
  }

  for (int y = 0; y < dst_height; y++)
  {
    for (int x = 0; x < dst_width; x++)
    {
      rotate_invtransf(x, y, &xl, &yl, cos0, sin0, dx, dy, sx, sy);
                   
      // if inside the original image broad area
      if (xl > 0.0 && yl > 0.0 && xl < src_width && yl < src_height)
      {
        if (order == 1)
          *dst_map = imBilinearInterpolation(src_width, src_height, src_map, xl, yl);
        else if (order == 3)
          *dst_map = imBicubicInterpolation(src_width, src_height, src_map, xl, yl, Dummy);
        else
          *dst_map = imZeroOrderInterpolation(src_width, src_height, src_map, xl, yl);
      }

      dst_map++;
    }

    if (!imCounterInc(counter))
      return 0;
  }

  return 1;
}
Пример #4
0
static int RotateCenter(int src_width, int src_height, DT *src_map, 
                        int dst_width, int dst_height, DT *dst_map, 
                        double cos0, double sin0, int counter, DTU Dummy, int order)
{
  float xl, yl;
  float dcx = float(dst_width/2.);
  float dcy = float(dst_height/2.);
  float scx = float(src_width/2.);
  float scy = float(src_height/2.);

  for (int y = 0; y < dst_height; y++)
  {
    for (int x = 0; x < dst_width; x++)
    {
      rotate_invtransf(x, y, &xl, &yl, cos0, sin0, dcx, dcy, scx, scy);
                   
      // if inside the original image broad area
      if (xl > 0.0 && yl > 0.0 && xl < src_width && yl < src_height)
      {
        if (order == 1)
          *dst_map = imBilinearInterpolation(src_width, src_height, src_map, xl, yl);
        else if (order == 3)
          *dst_map = imBicubicInterpolation(src_width, src_height, src_map, xl, yl, Dummy);
        else
          *dst_map = imZeroOrderInterpolation(src_width, src_height, src_map, xl, yl);
      }

      dst_map++;
    }

    if (!imCounterInc(counter))
      return 0;
  }

  return 1;
}