⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 image_component.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 3 页
字号:
      return(1);    }  if (QccIMGImageComponentWriteData(outfile, image_component))    {      QccErrorAddMessage("(QccIMGImageComponentWrite): Error calling QccIMGImageComponentWriteData()");      return(1);    }    QccFileClose(outfile);  return(0);}double QccIMGImageComponentClipPixel(double pixel_value){  double new_value;  if (pixel_value < 0)    new_value = 0;  else if (pixel_value > 255)    new_value = 255;  else    new_value = pixel_value;  return(new_value);}int QccIMGImageComponentClip(QccIMGImageComponent *image_component){  int row, col;  if (image_component == NULL)    return(0);  if (image_component->image == NULL)    return(0);  for (row = 0; row < image_component->num_rows; row++)    for (col = 0; col < image_component->num_cols; col++)      image_component->image[row][col] =        QccIMGImageComponentClipPixel(image_component->image[row][col]);  if (QccIMGImageComponentSetMaxMin(image_component))    {      QccErrorAddMessage("(QccIMGImageComponentClip): Error calling QccIMGImageComponentSetMaxMin()");      return(1);    }  return(0);}int QccIMGImageComponentNormalize(QccIMGImageComponent *image_component){  int row, col;  double range;  double min;  if (image_component == NULL)    return(0);  if (image_component->image == NULL)    return(0);  range = image_component->max_val - image_component->min_val;  min = image_component->min_val;  if (range == 0.0)    return(0);  for (row = 0; row < image_component->num_rows; row++)    for (col = 0; col < image_component->num_cols; col++)      image_component->image[row][col] =        255 * (image_component->image[row][col] - min) /        range;  if (QccIMGImageComponentSetMaxMin(image_component))    {      QccErrorAddMessage("(QccIMGImageComponentNormalize): Error calling QccIMGImageComponentSetMaxMin()");      return(1);    }  return(0);}int QccIMGImageComponentAbsoluteValue(QccIMGImageComponent *image_component){  int row, col;  if (image_component == NULL)    return(0);  if (image_component->image == NULL)    return(0);  for (row = 0; row < image_component->num_rows; row++)    for (col = 0; col < image_component->num_cols; col++)      image_component->image[row][col] =        fabs(image_component->image[row][col]);  if (QccIMGImageComponentSetMaxMin(image_component))    {      QccErrorAddMessage("(QccIMGImageComponentAbsoluteValue): Error calling QccIMGImageComponentSetMaxMin()");      return(1);    }  return(0);}double QccIMGImageComponentMean(const QccIMGImageComponent *image_component){  double sum = 0.0;  int row, col;    if (image_component == NULL)    return(0.0);  if (image_component->image == NULL)    return(0.0);  for (row = 0; row < image_component->num_rows; row++)    for (col = 0; col < image_component->num_cols; col++)      sum += image_component->image[row][col];    sum /= image_component->num_rows * image_component->num_cols;  return(sum);}double QccIMGImageComponentShapeAdaptiveMean(const QccIMGImageComponent                                             *image_component,                                             const QccIMGImageComponent                                             *alpha_mask){  double sum = 0.0;  int row, col;  int cnt = 0;  if (image_component == NULL)    return(0.0);  if (image_component->image == NULL)    return(0.0);  for (row = 0; row < image_component->num_rows; row++)    for (col = 0; col < image_component->num_cols; col++)      if (!QccAlphaTransparent(alpha_mask->image[row][col]))        {          sum += image_component->image[row][col];          cnt++;        }    sum /= cnt;  return(sum);}double QccIMGImageComponentVariance(const                                    QccIMGImageComponent *image_component){  double sum = 0.0;  double mean;  int row, col;    if (image_component == NULL)    return(0.0);  if (image_component->image == NULL)    return(0.0);  mean = QccIMGImageComponentMean(image_component);    for (row = 0; row < image_component->num_rows; row++)    for (col = 0; col < image_component->num_cols; col++)      sum +=        (image_component->image[row][col] - mean)*        (image_component->image[row][col] - mean);    sum /= image_component->num_rows * image_component->num_cols;  return(sum);}double QccIMGImageComponentShapeAdaptiveVariance(const QccIMGImageComponent                                                 *image_component,                                                 const QccIMGImageComponent                                                 *alpha_mask){  double sum = 0.0;  double mean;  int row, col;  int cnt = 0;  if (image_component == NULL)    return(0.0);  if (image_component->image == NULL)    return(0.0);  if (alpha_mask == NULL)    return(QccIMGImageComponentVariance(image_component));  if (alpha_mask->image == NULL)    return(QccIMGImageComponentVariance(image_component));  mean = QccIMGImageComponentShapeAdaptiveMean(image_component, alpha_mask);    for (row = 0; row < image_component->num_rows; row++)    for (col = 0; col < image_component->num_cols; col++)      if (!QccAlphaTransparent(alpha_mask->image[row][col]))        {          sum +=            (image_component->image[row][col] - mean)*            (image_component->image[row][col] - mean);          cnt++;        }    sum /= cnt;  return(sum);}int QccIMGImageComponentSubtractMean(QccIMGImageComponent                                      *image_component,                                     double *mean,                                     const QccSQScalarQuantizer *quantizer){  int row, col;  int partition;    double mean1;    if (image_component == NULL)    return(0);  if (image_component->image == NULL)    return(0);    mean1 = QccIMGImageComponentMean(image_component);    if (quantizer != NULL)    {      if (QccSQScalarQuantization(mean1, quantizer, NULL, &partition))        {          QccErrorAddMessage("(QccIMGImageComponentSubtractMean): Error calling QccSQScalarQuantization()");          return(1);        }      if (QccSQInverseScalarQuantization(partition, quantizer, &mean1))        {          QccErrorAddMessage("(QccIMGImageComponentSubtractMean): Error calling QccSQInverseScalarQuantization()");          return(1);        }    }    for (row = 0; row < image_component->num_rows; row++)    for (col = 0; col < image_component->num_cols; col++)      image_component->image[row][col] -= mean1;    if (mean != NULL)    *mean = mean1;    if (QccIMGImageComponentSetMaxMin(image_component))    {      QccErrorAddMessage("(QccIMGImageComponentSubtractMean): Error calling QccIMGImageComponentSetMaxMin()");      return(1);    }    return(0);}int QccIMGImageComponentAddMean(QccIMGImageComponent *image_component,                                double mean){  int row, col;    if (image_component == NULL)    return(0);  if (image_component->image == NULL)    return(0);    for (row = 0; row < image_component->num_rows; row++)    for (col = 0; col < image_component->num_cols; col++)      image_component->image[row][col] += mean;    if (QccIMGImageComponentSetMaxMin(image_component))    {      QccErrorAddMessage("(QccIMGImageComponentAddMean): Error calling QccIMGImageComponentSetMaxMin()");      return(1);    }    return(0);}double QccIMGImageComponentMSE(const QccIMGImageComponent *image_component1,                               const QccIMGImageComponent *image_component2){  double sum = 0.0;  int row, col;    if (image_component1 == NULL)    return(0.0);  if (image_component2 == NULL)    return(0.0);  if (image_component1->image == NULL)    return(0.0);  if (image_component2->image == NULL)    return(0.0);    if ((image_component2->num_rows != image_component1->num_rows) ||      (image_component2->num_cols != image_component1->num_cols))    return(0.0);  for (row = 0; row < image_component1->num_rows; row++)    for (col = 0; col < image_component1->num_cols; col++)      sum +=        (image_component1->image[row][col] -          image_component2->image[row][col])*        (image_component1->image[row][col] -          image_component2->image[row][col]);    sum /= image_component1->num_rows * image_component1->num_cols;  return(sum);}double QccIMGImageComponentShapeAdaptiveMSE(const QccIMGImageComponent                                            *image_component1,                                            const QccIMGImageComponent                                            *image_component2,                                            const QccIMGImageComponent                                            *alpha_mask){  double sum = 0.0;  int row, col;  int cnt = 0;  if (image_component1 == NULL)    return(0.0);  if (image_component2 == NULL)    return(0.0);  if ((image_component1->image == NULL) || (image_component2->image == NULL))    return(0.0);    if ((image_component2->num_rows != image_component1->num_rows) ||      (image_component2->num_cols != image_component1->num_cols))    return(0.0);  if (alpha_mask == NULL)    return(QccIMGImageComponentMSE(image_component1,                                   image_component2));  if (alpha_mask->image == NULL)    return(QccIMGImageComponentMSE(image_component1,                                   image_component2));  if ((alpha_mask->num_rows != image_component1->num_rows) ||      (alpha_mask->num_cols != image_component1->num_cols))    return(0.0);  for (row = 0; row < image_component1->num_rows; row++)    for (col = 0; col < image_component1->num_cols; col++)      if (!QccAlphaTransparent(alpha_mask->image[row][col]))        {          sum +=            (image_component1->image[row][col] -              image_component2->image[row][col])*            (image_component1->image[row][col] -              image_component2->image[row][col]);          cnt++;        }    sum /= cnt;  return(sum);}double QccIMGImageComponentMAE(const QccIMGImageComponent *image_component1,                               const QccIMGImageComponent *image_component2){  int row, col;  double mae = 0;  if (image_component1 == NULL)    return(0.0);  if (image_component2 == NULL)    return(0.0);  if ((image_component1->image == NULL) || (image_component2->image == NULL))    return(0.0);    if ((image_component2->num_rows != image_component1->num_rows) ||      (image_component2->num_cols != image_component1->num_cols))    return(0.0);  for (row = 0; row < image_component1->num_rows; row++)    for (col = 0; col < image_component1->num_cols; col++)      mae = QccMathMax(mae,                       fabs(image_component1->image[row][col] -                             image_component2->image[row][col]));  return(mae);}double QccIMGImageComponentShapeAdaptiveMAE(const QccIMGImageComponent                                            *image_component1,                                            const QccIMGImageComponent                                            *image_component2,                                            const QccIMGImageComponent                                            *alpha_mask){  int row, col;  double mae = 0;  if (image_component1 == NULL)    return(0.0);  if (image_component2 == NULL)    return(0.0);  if ((image_component1->image == NULL) || (image_component2->image == NULL))    return(0.0);    if ((image_component2->num_rows != image_component1->num_rows) ||      (image_component2->num_cols != image_component1->num_cols))    return(0.0);  if (alpha_mask == NULL)    return(QccIMGImageComponentMAE(image_component1,                                   image_component2));  if (alpha_mask->image == NULL)    return(QccIMGImageComponentMAE(image_component1,                                   image_component2));  if ((alpha_mask->num_rows != image_component1->num_rows) ||      (alpha_mask->num_cols != image_component1->num_cols))    return(0.0);  for (row = 0; row < image_component1->num_rows; row++)    for (col = 0; col < image_component1->num_cols; col++)      if (!QccAlphaTransparent(alpha_mask->image[row][col]))        mae = QccMathMax(mae,                         fabs(image_component1->image[row][col] -                               image_component2->image[row][col]));  return(mae);}int QccIMGImageComponentExtractBlock(const                                     QccIMGImageComponent *image_component,                                     int image_row, int image_col,                                     QccMatrix block,                                     int block_num_rows, int block_num_cols){  int block_row, block_col;  int current_image_row, current_image_col;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -