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

📄 image_cube.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 3 页
字号:
    if ((infile = QccFileOpen(image_cube->filename, "r")) == NULL)    {      QccErrorAddMessage("(QccIMGImageCubeRead): Error opening %s for reading",                         image_cube->filename);      return(1);    }    if (QccIMGImageCubeReadHeader(infile, image_cube))    {      QccErrorAddMessage("(QccIMGImageCubeRead): Error calling QccIMGImageCubeReadHeader()");      return(1);    }    if (QccIMGImageCubeAlloc(image_cube))    {      QccErrorAddMessage("(QccIMGImageCubeRead): Error calling QccIMGImageCubeAlloc()");      return(1);    }    if (QccIMGImageCubeReadData(infile, image_cube))    {      QccErrorAddMessage("(QccIMGImageCubeRead): Error calling QccIMGImageCubeReadData()");      return(1);    }    QccFileClose(infile);  return(0);}static int QccIMGImageCubeWriteHeader(FILE *outfile,                                      const QccIMGImageCube *image_cube){  if ((outfile == NULL) || (image_cube == NULL))    return(0);    if (QccFileWriteMagicNumber(outfile, QCCIMGIMAGECUBE_MAGICNUM))    goto Error;    fprintf(outfile, "%d %d %d\n",          image_cube->num_cols,          image_cube->num_rows,          image_cube->num_frames);  if (ferror(outfile))    goto Error;    fprintf(outfile, "% 16.9e % 16.9e\n",          image_cube->min_val,          image_cube->max_val);  if (ferror(outfile))    goto Error;    return(0);   Error:  QccErrorAddMessage("(QccIMGImageCubeWriteHeader): Error writing header to %s",                     image_cube->filename);  return(1);}static int QccIMGImageCubeWriteData(FILE *outfile,                                    const QccIMGImageCube *image_cube){  int frame, row, col;    if ((image_cube == NULL) ||      (outfile == NULL))    return(0);    for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        if (QccFileWriteDouble(outfile,                               image_cube->volume[frame][row][col]))          {            QccErrorAddMessage("(QccIMGImageCubeWriteData): Error calling QccFileWriteDouble()");            return(1);          }    return(0);}int QccIMGImageCubeWrite(const QccIMGImageCube *image_cube){  FILE *outfile;    if (image_cube == NULL)    return(0);    if ((outfile = QccFileOpen(image_cube->filename, "w")) == NULL)    {      QccErrorAddMessage("(QccIMGImageCubeWrite): Error opening %s for writing",                         image_cube->filename);      return(1);    }    if (QccIMGImageCubeWriteHeader(outfile, image_cube))    {      QccErrorAddMessage("(QccIMGImageCubeWrite): Error calling QccIMGImageCubeWriteHeader()");      return(1);    }  if (QccIMGImageCubeWriteData(outfile, image_cube))    {      QccErrorAddMessage("(QccIMGImageCubeWrite): Error calling QccIMGImageCubeWriteData()");      return(1);    }    QccFileClose(outfile);  return(0);}int QccIMGImageCubeClip(QccIMGImageCube *image_cube){  int frame, row, col;    if (image_cube == NULL)    return(0);  if (image_cube->volume == NULL)    return(0);    for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        image_cube->volume[frame][row][col] =          QccIMGImageComponentClipPixel(image_cube->volume[frame][row][col]);    if (QccIMGImageCubeSetMaxMin(image_cube))    {      QccErrorAddMessage("(QccIMGImageCubeClip): Error calling QccIMGImageCubeSetMaxMin()");      return(1);    }    return(0);}int QccIMGImageCubeNormalize(QccIMGImageCube *image_cube,                             double upper_bound,                             double lower_bound){  int frame, row, col;  double range;  double min;    if (image_cube == NULL)    return(0);  if (image_cube->volume == NULL)    return(0);    range = image_cube->max_val - image_cube->min_val;  min = image_cube->min_val;    if (range == 0.0)    return(0);  for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        image_cube->volume[frame][row][col] =          (upper_bound - lower_bound) *          (image_cube->volume[frame][row][col] - min) /          range + lower_bound;    QccIMGImageCubeSetMin(image_cube);  QccIMGImageCubeSetMax(image_cube);    return(0);}int QccIMGImageCubeAbsoluteValue(QccIMGImageCube *image_cube){  int frame, row, col;    if (image_cube == NULL)    return(0);  if (image_cube->volume == NULL)    return(0);    for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        image_cube->volume[frame][row][col] =          fabs(image_cube->volume[frame][row][col]);    QccIMGImageCubeSetMin(image_cube);  QccIMGImageCubeSetMax(image_cube);    return(0);}double QccIMGImageCubeMean(const QccIMGImageCube *image_cube){  double sum = 0.0;  int frame, row, col;    if (image_cube == NULL)    return(0.0);  if (image_cube->volume == NULL)    return(0.0);    for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        sum += image_cube->volume[frame][row][col] /          image_cube->num_rows / image_cube->num_cols / image_cube->num_frames;    return(sum);}double QccIMGImageCubeShapeAdaptiveMean(const QccIMGImageCube *image_cube,                                        const QccIMGImageCube *alpha_mask){  double sum = 0.0;  int frame, row, col;  int cnt = 0;    if (image_cube == NULL)    return(0.0);  if (image_cube->volume == NULL)    return(0.0);    for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        if (!QccAlphaTransparent(alpha_mask->volume[frame][row][col]))          cnt++;  for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        if (!QccAlphaTransparent(alpha_mask->volume[frame][row][col]))          sum += image_cube->volume[frame][row][col] / cnt;    return(sum);}double QccIMGImageCubeVariance(const QccIMGImageCube *image_cube){  double sum = 0.0;  double mean;  int frame, row, col;    if (image_cube == NULL)    return(0.0);  if (image_cube->volume == NULL)    return(0.0);    mean = QccIMGImageCubeMean(image_cube);    for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        sum +=          (image_cube->volume[frame][row][col] - mean)*          (image_cube->volume[frame][row][col] - mean) /          image_cube->num_rows / image_cube->num_cols / image_cube->num_frames;  return(sum);}double QccIMGImageCubeShapeAdaptiveVariance(const QccIMGImageCube *image_cube,                                            const QccIMGImageCube *alpha_mask){  double sum = 0.0;  double mean;  int frame, row, col;  int cnt = 0;    if (image_cube == NULL)    return(0.0);  if (image_cube->volume == NULL)    return(0.0);    if (alpha_mask == NULL)    return(QccIMGImageCubeVariance(image_cube));  if (alpha_mask->volume == NULL)    return(QccIMGImageCubeVariance(image_cube));    mean = QccIMGImageCubeShapeAdaptiveMean(image_cube, alpha_mask);    for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        if (!QccAlphaTransparent(alpha_mask->volume[frame][row][col]))          cnt++;  for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        if (!QccAlphaTransparent(alpha_mask->volume[frame][row][col]))          sum +=            (image_cube->volume[frame][row][col] - mean) *            (image_cube->volume[frame][row][col] - mean) / cnt;  return(sum);}int QccIMGImageCubeSubtractMean(QccIMGImageCube *image_cube,                                double *mean,                                const QccSQScalarQuantizer *quantizer){  int frame, row, col;  int partition;    double mean1;    if (image_cube == NULL)    return(0);  if (image_cube->volume == NULL)    return(0);    mean1 = QccIMGImageCubeMean(image_cube);    if (quantizer != NULL)    {      if (QccSQScalarQuantization(mean1, quantizer, NULL, &partition))        {          QccErrorAddMessage("(QccIMGImageCubeSubtractMean): Error calling QccSQScalarQuantization()");          return(1);        }      if (QccSQInverseScalarQuantization(partition, quantizer, &mean1))        {          QccErrorAddMessage("(QccIMGImageCubeSubtractMean): Error calling QccSQInverseScalarQuantization()");          return(1);        }    }    for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        image_cube->volume[frame][row][col] -= mean1;    if (mean != NULL)    *mean = mean1;    QccIMGImageCubeSetMin(image_cube);  QccIMGImageCubeSetMax(image_cube);    return(0);}int QccIMGImageCubeAddMean(QccIMGImageCube *image_cube,                           double mean){  int frame, row, col;    if (image_cube == NULL)    return(0);  if (image_cube->volume == NULL)    return(0);    for (frame = 0; frame < image_cube->num_frames; frame++)    for (row = 0; row < image_cube->num_rows; row++)      for (col = 0; col < image_cube->num_cols; col++)        image_cube->volume[frame][row][col] += mean;    QccIMGImageCubeSetMin(image_cube);  QccIMGImageCubeSetMax(image_cube);    return(0);}double QccIMGImageCubeMSE(const QccIMGImageCube *image_cube1,                          const QccIMGImageCube *image_cube2){  double sum = 0.0;

⌨️ 快捷键说明

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