コード例 #1
0
ファイル: im_morphology_gray.cpp プロジェクト: Vulcanior/IUP
int imProcessGrayMorphConvolve(const imImage* src_image, imImage* dst_image, const imImage *kernel, int ismax)
{
  int ret = 0;

  int counter = imProcessCounterBegin("Gray Morphological Convolution");
  const char* msg = (const char*)imImageGetAttribute(kernel, "Description", NULL, NULL);
  if (!msg) msg = "Processing...";
  imCounterTotal(counter, src_image->depth*src_image->height, msg);

  imImage* fkernel = NULL;
    
  if ((src_image->data_type == IM_FLOAT || src_image->data_type == IM_DOUBLE) && 
       kernel->data_type != src_image->data_type)
  {
    fkernel = imImageCreate(kernel->width, kernel->height, IM_GRAY, src_image->data_type);
    imProcessConvertDataType(kernel, fkernel, 0, 0, 0, IM_CAST_DIRECT);
    kernel = fkernel;
  }

  for (int i = 0; i < src_image->depth; i++)
  {
    switch(src_image->data_type)
    {
    case IM_BYTE:
      ret = DoGrayMorphConvolve((imbyte*)src_image->data[i], (imbyte*)dst_image->data[i], src_image->width, src_image->height, kernel, counter, ismax, (int)0);
      break;                                                                                
    case IM_SHORT:
      ret = DoGrayMorphConvolve((short*)src_image->data[i], (short*)dst_image->data[i], src_image->width, src_image->height, kernel, counter, ismax, (int)0);
      break;                                                                                
    case IM_USHORT:
      ret = DoGrayMorphConvolve((imushort*)src_image->data[i], (imushort*)dst_image->data[i], src_image->width, src_image->height, kernel, counter, ismax, (int)0);
      break;                                                                                
    case IM_INT:                                                                           
      ret = DoGrayMorphConvolve((int*)src_image->data[i], (int*)dst_image->data[i], src_image->width, src_image->height, kernel, counter, ismax, (int)0);
      break;                                                                                
    case IM_FLOAT:
      ret = DoGrayMorphConvolve((float*)src_image->data[i], (float*)dst_image->data[i], src_image->width, src_image->height, kernel, counter, ismax, (float)0);
      break;                                                                                
    case IM_DOUBLE:
      ret = DoGrayMorphConvolve((double*)src_image->data[i], (double*)dst_image->data[i], src_image->width, src_image->height, kernel, counter, ismax, (double)0);
      break;
    }
    
    if (!ret) 
      break;
  }

  if (fkernel) imImageDestroy(fkernel);
  imProcessCounterEnd(counter);

  return ret;
}
コード例 #2
0
ファイル: im_resize.cpp プロジェクト: LuaDist/im
int imProcessResize(const imImage* src_image, imImage* dst_image, int order)
{
  int ret = 0;
  int counter = imProcessCounterBegin("Resize");
  const char* int_msg = (order == 3)? "Bicubic Interpolation": (order == 1)? "Bilinear Interpolation": "Zero Order Interpolation";
  int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth;
  imCounterTotal(counter, src_depth*dst_image->height, int_msg);

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

  imProcessCounterEnd(counter);
  return ret;
}
コード例 #3
0
ファイル: im_render.cpp プロジェクト: Vulcanior/IUP
int imProcessRenderCondOp(imImage* image, imRenderCondFunc render_func, const char* render_name, float* param)
{
  int ret = 0;

  int counter = imProcessCounterBegin(render_name);
  imCounterTotal(counter, image->depth*image->height, "Rendering...");

  for (int d = 0; d < image->depth; d++)
  {
    switch(image->data_type)
    {
    case IM_BYTE:
      ret = DoRenderCondOp((imbyte*)image->data[d], image->width, image->height, d, render_func, param, counter);
      break;                                                                                
    case IM_SHORT:                                                                           
      ret = DoRenderCondOp((short*)image->data[d], image->width, image->height, d, render_func, param, counter);
      break;                                                                                
    case IM_USHORT:                                                                           
      ret = DoRenderCondOp((imushort*)image->data[d], image->width, image->height, d, render_func, param, counter);
      break;                                                                                
    case IM_INT:                                                                           
      ret = DoRenderCondOp((int*)image->data[d], image->width, image->height, d, render_func, param, counter);
      break;                                                                                
    case IM_FLOAT:                                                                           
      ret = DoRenderCondOp((float*)image->data[d], image->width, image->height, d, render_func, param, counter);
      break;                                                                                
    case IM_DOUBLE:
      ret = DoRenderCondOp((double*)image->data[d], image->width, image->height, d, render_func, param, counter);
      break;
    }

    if (!ret) 
      break;
  }

  imProcessCounterEnd(counter);

  return ret;
}
コード例 #4
0
ファイル: im_convertbitmap.cpp プロジェクト: kmx/alien-iup
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;
}