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

📄 image_cube.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 3 页
字号:
  int frame, row, col;    if (image_cube1 == NULL)    return(0.0);  if (image_cube2 == NULL)    return(0.0);  if ((image_cube1->volume == NULL) || (image_cube2->volume == NULL))    return(0.0);    for (frame = 0; frame < image_cube1->num_frames; frame++)    for (row = 0; row < image_cube1->num_rows; row++)      for (col = 0; col < image_cube1->num_cols; col++)        sum +=          (image_cube1->volume[frame][row][col] -           image_cube2->volume[frame][row][col]) *          (image_cube1->volume[frame][row][col] -           image_cube2->volume[frame][row][col]) /          image_cube1->num_rows /          image_cube1->num_cols /          image_cube1->num_frames;  return(sum);}double QccIMGImageCubeShapeAdaptiveMSE(const QccIMGImageCube                                       *image_cube1,                                       const QccIMGImageCube                                       *image_cube2,                                       const QccIMGImageCube                                       *alpha_mask){  double sum = 0.0;  int frame, row, col;  int cnt = 0;    if (image_cube1 == NULL)    return(0.0);  if (image_cube2 == NULL)    return(0.0);  if ((image_cube1->volume == NULL) || (image_cube2->volume == NULL))    return(0.0);    if (alpha_mask == NULL)    return(QccIMGImageCubeMSE(image_cube1,                              image_cube2));  if (alpha_mask->volume == NULL)    return(QccIMGImageCubeMSE(image_cube1,                              image_cube2));    for (frame = 0; frame < image_cube1->num_frames; frame++)    for (row = 0; row < image_cube1->num_rows; row++)      for (col = 0; col < image_cube1->num_cols; col++)        if (!QccAlphaTransparent(alpha_mask->volume[frame][row][col]))          cnt++;    for (frame = 0; frame < image_cube1->num_frames; frame++)    for (row = 0; row < image_cube1->num_rows; row++)      for (col = 0; col < image_cube1->num_cols; col++)        if (!QccAlphaTransparent(alpha_mask->volume[frame][row][col]))          sum +=            (image_cube1->volume[frame][row][col] -             image_cube2->volume[frame][row][col]) *            (image_cube1->volume[frame][row][col] -             image_cube2->volume[frame][row][col]) / cnt;  return(sum);}double QccIMGImageCubeMAE(const QccIMGImageCube *image_cube1,                          const QccIMGImageCube *image_cube2){  int frame, row, col;  double mae = 0;    if (image_cube1 == NULL)    return(0.0);  if (image_cube2 == NULL)    return(0.0);  if ((image_cube1->volume == NULL) || (image_cube2->volume == NULL))    return(0.0);    for (frame = 0; frame < image_cube1->num_frames; frame++)    for (row = 0; row < image_cube1->num_rows; row++)      for (col = 0; col < image_cube1->num_cols; col++)        mae = QccMathMax(mae,                         fabs(image_cube1->volume[frame][row][col] -                              image_cube2->volume[frame][row][col]));  return(mae);}double QccIMGImageCubeShapeAdaptiveMAE(const QccIMGImageCube                                       *image_cube1,                                       const QccIMGImageCube                                       *image_cube2,                                       const QccIMGImageCube                                       *alpha_mask){  int frame, row, col;  double mae = 0;    if (image_cube1 == NULL)    return(0.0);  if (image_cube2 == NULL)    return(0.0);  if ((image_cube1->volume == NULL) || (image_cube2->volume == NULL))    return(0.0);    if (alpha_mask == NULL)    return(QccIMGImageCubeMAE(image_cube1,                              image_cube2));  if (alpha_mask->volume == NULL)    return(QccIMGImageCubeMAE(image_cube1,                              image_cube2));    for (frame = 0; frame < image_cube1->num_frames; frame++)    for (row = 0; row < image_cube1->num_rows; row++)      for (col = 0; col < image_cube1->num_cols; col++)        if (!QccAlphaTransparent(alpha_mask->volume[frame][row][col]))          mae = QccMathMax(mae,                           fabs(image_cube1->volume[frame][row][col] -                                image_cube2->volume[frame][row][col]));    return(mae);}int QccIMGImageCubeExtractBlock(const QccIMGImageCube *image_cube,                                int image_frame,                                int image_row,                                int image_col,                                QccVolume block,                                int block_num_frames,                                int block_num_rows,                                int block_num_cols){  int block_frame, block_row, block_col;  int current_image_frame, current_image_row, current_image_col;    for (block_frame = 0; block_frame < block_num_frames; block_frame++)    for (block_row = 0; block_row < block_num_rows; block_row++)      for (block_col = 0; block_col < block_num_cols; block_col++)        {          current_image_frame = image_frame + block_frame;          current_image_row = image_row + block_row;          current_image_col = image_col + block_col;          block[block_frame][block_row][block_col] =            ((current_image_frame >= 0) &&             (current_image_frame < image_cube->num_frames) &&             (current_image_row >= 0) &&             (current_image_row < image_cube->num_rows) &&             (current_image_col >= 0) &&             (current_image_col < image_cube->num_cols)) ?            image_cube->volume            [current_image_frame][current_image_row][current_image_col] : 0;        }    return(0);}int QccIMGImageCubeInsertBlock(QccIMGImageCube *image_cube,                               int image_frame,                               int image_row,                               int image_col,                               const QccVolume block,                               int block_num_frames,                               int block_num_rows,                               int block_num_cols){  int block_frame, block_row, block_col;  int current_image_frame, current_image_row, current_image_col;    for (block_frame = 0; block_frame < block_num_frames; block_frame++)    for (block_row = 0; block_row < block_num_rows; block_row++)      for (block_col = 0; block_col < block_num_cols; block_col++)        {          current_image_frame = image_frame + block_frame;          current_image_row = image_row + block_row;          current_image_col = image_col + block_col;          if ((current_image_frame >= 0) &&              (current_image_frame < image_cube->num_frames) &&              (current_image_row >= 0) &&              (current_image_row < image_cube->num_rows) &&              (current_image_col >= 0) &&              (current_image_col < image_cube->num_cols))            image_cube->volume              [current_image_frame][current_image_row][current_image_col] =              block[block_frame][block_row][block_col];        }    return(0);}int QccIMGImageCubeCopy(QccIMGImageCube *image_cube1,                        const QccIMGImageCube *image_cube2){  int frame, row, col;    if ((image_cube1 == NULL) ||      (image_cube2 == NULL))    return(0);    if ((image_cube2->volume == NULL) ||      (image_cube2->num_frames <= 0) ||      (image_cube2->num_rows <= 0) ||      (image_cube2->num_cols <= 0))    return(0);    if (image_cube1->volume == NULL)    {      image_cube1->num_frames = image_cube2->num_frames;      image_cube1->num_rows = image_cube2->num_rows;      image_cube1->num_cols = image_cube2->num_cols;      if (QccIMGImageCubeAlloc(image_cube1))        {          QccErrorAddMessage("(QccIMGImageCubeCopy): Error calling QccIMGImageCubeAlloc()");          return(1);        }    }  else    {      if ((image_cube1->num_frames != image_cube2->num_frames) ||          (image_cube1->num_rows != image_cube2->num_rows) ||          (image_cube1->num_cols != image_cube2->num_cols))        {          QccErrorAddMessage("(QccIMGImageCubeCopy): Image-cube arrays have different sizes");          return(1);        }    }  for (frame = 0; frame < image_cube1->num_frames; frame++)    for (row = 0; row < image_cube1->num_rows; row++)      for (col = 0; col < image_cube1->num_cols; col++)        image_cube1->volume[frame][row][col] =          image_cube2->volume[frame][row][col];    QccIMGImageCubeSetMin(image_cube1);  QccIMGImageCubeSetMax(image_cube1);    return(0);  }int QccIMGImageCubeAdd(const QccIMGImageCube *image_cube1,                       const QccIMGImageCube *image_cube2,                       QccIMGImageCube *image_cube3){  int frame, row, col;    if (image_cube1 == NULL)    return(0);  if (image_cube2 == NULL)    return(0);  if (image_cube3 == NULL)    return(0);    if (image_cube1->volume == NULL)    return(0);  if (image_cube2->volume == NULL)    return(0);  if (image_cube3->volume == NULL)    return(0);    if ((image_cube1->num_frames != image_cube2->num_frames) ||      (image_cube1->num_rows != image_cube2->num_rows) ||      (image_cube1->num_cols != image_cube2->num_cols) ||      (image_cube1->num_frames != image_cube3->num_frames) ||      (image_cube1->num_rows != image_cube3->num_rows) ||      (image_cube1->num_cols != image_cube3->num_cols))    {      QccErrorAddMessage("(QccIMGImageCubeSubtract): Image cubes must have same number of rows, columns, and frames");      return(1);    }    for (frame = 0; frame < image_cube1->num_frames; frame++)    for (row = 0; row < image_cube1->num_rows; row++)      for (col = 0; col < image_cube1->num_cols; col++)        image_cube3->volume[frame][row][col] =          image_cube1->volume[frame][row][col] +          image_cube2->volume[frame][row][col];    QccIMGImageCubeSetMin(image_cube3);  QccIMGImageCubeSetMax(image_cube3);    return(0);}int QccIMGImageCubeSubtract(const QccIMGImageCube *image_cube1,                            const QccIMGImageCube *image_cube2,                            QccIMGImageCube *image_cube3){  int frame, row, col;    if (image_cube1 == NULL)    return(0);  if (image_cube2 == NULL)    return(0);  if (image_cube3 == NULL)    return(0);    if (image_cube1->volume == NULL)    return(0);  if (image_cube2->volume == NULL)    return(0);  if (image_cube3->volume == NULL)    return(0);    if ((image_cube1->num_frames != image_cube2->num_frames) ||      (image_cube1->num_rows != image_cube2->num_rows) ||      (image_cube1->num_cols != image_cube2->num_cols) ||      (image_cube1->num_frames != image_cube3->num_frames) ||      (image_cube1->num_rows != image_cube3->num_rows) ||      (image_cube1->num_cols != image_cube3->num_cols))    {      QccErrorAddMessage("(QccIMGImageCubeSubtract): Image cubes must have same number of rows, columns, and frames");      return(1);    }    for (frame = 0; frame < image_cube1->num_frames; frame++)    for (row = 0; row < image_cube1->num_rows; row++)      for (col = 0; col < image_cube1->num_cols; col++)        image_cube3->volume[frame][row][col] =          image_cube1->volume[frame][row][col] -          image_cube2->volume[frame][row][col];    QccIMGImageCubeSetMin(image_cube3);  QccIMGImageCubeSetMax(image_cube3);    return(0);}int QccIMGImageCubeExtractFrame(const QccIMGImageCube *image_cube,                                int frame,                                QccIMGImageComponent *image_component){  int row, col;  if (image_cube == NULL)    return(0);  if (image_component == NULL)    return(0);  if ((image_cube->num_rows != image_component->num_rows) ||      (image_cube->num_cols != image_component->num_cols))    {      QccErrorAddMessage("(QccIMGImageCubeExtractFrame): Image-component size not the same as image-cube size");      return(1);    }  if ((frame < 0) || (frame >= image_cube->num_frames))    {      QccErrorAddMessage("(QccIMGImageCubeExtractFrame): Invalid frame number");      return(1);    }  for (row = 0; row < image_cube->num_rows; row++)    for (col = 0; col < image_cube->num_cols; col++)      image_component->image[row][col] =        image_cube->volume[frame][row][col];  if (QccIMGImageComponentSetMaxMin(image_component))    {      QccErrorAddMessage("(QccIMGImageCubeExtractFrame): Error calling QccIMGImageComponentSetMaxMin()");      return(1);    }  return(0);}

⌨️ 快捷键说明

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