예제 #1
0
int imProcessHoughLines(const imImage* src_image, imImage *dst_image)
{
  int counter = imCounterBegin("Hough Line Transform");
  imCounterTotal(counter, src_image->height, "Processing...");

  int ret = houghLine(src_image, dst_image, counter);

  imCounterEnd(counter);

  return ret;
}
예제 #2
0
파일: im_file.cpp 프로젝트: LuaDist/im
imFile* imFileOpenAs(const char* file_name, const char* format, int *error)
{
  assert(file_name);

  imFileFormatBase* ifileformat = imFileFormatBaseOpenAs(file_name, format, error);
  if (!ifileformat) 
    return NULL;

  imFileClear(ifileformat);

  ifileformat->attrib_table = new imAttribTable(599);
  imFileSetBaseAttributes(ifileformat);

  ifileformat->counter = imCounterBegin(file_name);

  return ifileformat;
}
예제 #3
0
int imProcessRotateRef(const imImage* src_image, imImage* dst_image, double cos0, double sin0, int x, int y, int to_origin, int order)
{
  int ret = 0;

  int counter = imCounterBegin("RotateRef");
  int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth;
  imCounterTotal(counter, src_depth*dst_image->height, "Processing...");  /* size of the destiny image */

  if (src_image->color_space == IM_MAP)
  {
    ret = Rotate(src_image->width, src_image->height, (imbyte*)src_image->data[0],  dst_image->width, dst_image->height, (imbyte*)dst_image->data[0], cos0, sin0, x, y, to_origin, counter, float(0), 0);
  }
  else
  {
    for (int i = 0; i < src_depth; i++)
    {
      switch(src_image->data_type)
      {
      case IM_BYTE:
        ret = Rotate(src_image->width, src_image->height, (imbyte*)src_image->data[i], dst_image->width, dst_image->height, (imbyte*)dst_image->data[i], cos0, sin0, x, y, to_origin, counter, float(0), order);
        break;
      case IM_USHORT:
        ret = Rotate(src_image->width, src_image->height, (imushort*)src_image->data[i], dst_image->width, dst_image->height, (imushort*)dst_image->data[i], cos0, sin0, x, y, to_origin, counter, float(0), order);
        break;
      case IM_INT:
        ret = Rotate(src_image->width, src_image->height, (int*)src_image->data[i], dst_image->width, dst_image->height, (int*)dst_image->data[i], cos0, sin0, x, y, to_origin, counter, float(0), order);
        break;
      case IM_FLOAT:
        ret = Rotate(src_image->width, src_image->height, (float*)src_image->data[i], dst_image->width, dst_image->height, (float*)dst_image->data[i], cos0, sin0, x, y, to_origin, counter, float(0), order);
        break;
      case IM_CFLOAT:
        ret = Rotate(src_image->width, src_image->height, (imcfloat*)src_image->data[i], dst_image->width, dst_image->height, (imcfloat*)dst_image->data[i], cos0, sin0, x, y, to_origin, counter, imcfloat(0,0), order);
        break;
      }

      if (!ret)
        break;
    }
   }

  imCounterEnd(counter);

  return ret;
}
예제 #4
0
파일: im_file.cpp 프로젝트: LuaDist/im
imFile* imFileNew(const char* file_name, const char* format, int *error)
{
  assert(file_name);

  imFileFormatBase* ifileformat = imFileFormatBaseNew(file_name, format, error);
  if (!ifileformat) 
    return NULL;

  imFileClear(ifileformat);

  ifileformat->is_new = 1;
  ifileformat->image_count = 0;
  ifileformat->compression[0] = 0;

  ifileformat->attrib_table = new imAttribTable(101);

  ifileformat->counter = imCounterBegin(file_name);

  return ifileformat;
}
예제 #5
0
int imProcessSwirl(const imImage* src_image, imImage* dst_image, float k, int order)
{
  int ret = 0;

  int counter = imCounterBegin("Swirl Distort");
  int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth;
  imCounterTotal(counter, src_depth*dst_image->height, "Processing...");  /* size of the destiny image */

  for (int i = 0; i < src_depth; i++)
  {
    switch(src_image->data_type)
    {
    case IM_BYTE:
      ret = Swirl(src_image->width, src_image->height, (imbyte*)src_image->data[i], (imbyte*)dst_image->data[i], k, counter, float(0), order);
      break;
    case IM_USHORT:
      ret = Swirl(src_image->width, src_image->height, (imushort*)src_image->data[i], (imushort*)dst_image->data[i], k, counter, float(0), order);
      break;
    case IM_INT:
      ret = Swirl(src_image->width, src_image->height, (int*)src_image->data[i], (int*)dst_image->data[i], k, counter, float(0), order);
      break;
    case IM_FLOAT:
      ret = Swirl(src_image->width, src_image->height, (float*)src_image->data[i], (float*)dst_image->data[i], k, counter, float(0), order);
      break;
    case IM_CFLOAT:
      ret = Swirl(src_image->width, src_image->height, (imcfloat*)src_image->data[i], (imcfloat*)dst_image->data[i], k, counter, imcfloat(0,0), order);
      break;
    }

    if (!ret)
      break;
  }

  imCounterEnd(counter);

  return ret;
}
예제 #6
0
int imConvertToBitmap(const imImage* src_image, imImage* dst_image, int cpx2real, float gamma, int absolute, int cast_mode)
#endif
{
    assert(src_image);
    assert(dst_image);

    if (!imImageMatchSize(src_image, dst_image) || !imImageIsBitmap(dst_image))
        return IM_ERR_DATA;

#ifdef IM_PROCESS
    int counter = imProcessCounterBegin("Building Bitmap");
#else
    int counter = imCounterBegin("Building Bitmap");
#endif

    int ret;
    if (src_image->data_type == IM_BYTE)
    {
        // NO data type conversion, only color mode conversion
#ifdef IM_PROCESS
        ret = imProcessConvertColorSpace(src_image, dst_image);
#else
        ret = imConvertColorSpace(src_image, dst_image);
#endif
    }
    else
    {
        if (src_image->color_space == IM_RGB ||
                src_image->color_space == IM_GRAY)
        {
            // data type conversion, but NO color mode conversion
#ifdef IM_PROCESS
            ret = imProcessConvertDataType(src_image, dst_image, cpx2real, gamma, absolute, cast_mode);
#else
            ret = imConvertDataType(src_image, dst_image, cpx2real, gamma, absolute, cast_mode);
#endif
        }
        else
        {
            // data type conversion AND color mode conversion
            imImage* temp_image = imImageCreate(src_image->width, src_image->height, dst_image->color_space, src_image->data_type);
            if (!temp_image)
                ret = IM_ERR_MEM;
            else
            {
                // first convert color_mode in the bigger precision
#ifdef IM_PROCESS
                ret = imProcessConvertColorSpace(src_image, temp_image);
#else
                ret = imConvertColorSpace(src_image, temp_image);
#endif
                if (ret == IM_ERR_NONE)
                {
                    // second just convert data type
#ifdef IM_PROCESS
                    ret = imProcessConvertDataType(temp_image, dst_image, cpx2real, gamma, absolute, cast_mode);
#else
                    ret = imConvertDataType(temp_image, dst_image, cpx2real, gamma, absolute, cast_mode);
#endif
                }
                imImageDestroy(temp_image);
            }
        }
    }

#ifdef IM_PROCESS
    imProcessCounterEnd(counter);
#else
    imCounterEnd(counter);
#endif

    return ret;
}