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

📄 klt.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 2 页
字号:
    }    QccFileClose(outfile);  return(0);}static int QccHYPkltMean(const QccIMGImageCube *image,                         QccVector mean){  int num_bands;  int row, col, band;  num_bands = image->num_frames;  for (band = 0; band < num_bands; band++)    {      mean[band] = 0;      for (row = 0; row < image->num_rows; row++)        for (col = 0; col < image->num_cols; col++)          mean[band] +=            image->volume[band][row][col];      mean[band] /=        (image->num_rows * image->num_cols);    }  return(0);}static int QccHYPkltCovariance(const QccIMGImageCube *image,                               const QccVector mean,                               QccMatrix covariance){  int num_bands;  int row, col;  int covariance_row, covariance_col;  num_bands = image->num_frames;  for (covariance_row = 0; covariance_row < num_bands; covariance_row++)    for (covariance_col = 0; covariance_col < num_bands; covariance_col++)      if (covariance_col >= covariance_row)        {          covariance[covariance_row][covariance_col] = 0;                    for (row = 0; row < image->num_rows; row++)            for (col = 0; col < image->num_cols; col++)              covariance[covariance_row][covariance_col] +=                image->volume[covariance_row][row][col] *                image->volume[covariance_col][row][col];          covariance[covariance_row][covariance_col] /=            (image->num_rows * image->num_cols);          covariance[covariance_row][covariance_col] -=            mean[covariance_row] * mean[covariance_col];                  }      else        covariance[covariance_row][covariance_col] =          covariance[covariance_col][covariance_row];  return(0);}int QccHYPkltTrain(const QccIMGImageCube *image,                   QccHYPklt *klt){  int return_value;  QccMatrix covariance = NULL;  int num_bands;  if (image == NULL)    return(0);  if (klt == NULL)    return(0);  num_bands = image->num_frames;  if (num_bands != klt->num_bands)    {      QccErrorAddMessage("(QccHYPkltTrain): Number of bands in KLT (%d) does not match that of image cube (%d)",                         klt->num_bands,                         num_bands);      goto Error;    }  if (QccHYPkltMean(image, klt->mean))    {      QccErrorAddMessage("(QccHYPkltTrain): Error calling QccHYPkltMean()");      goto Error;    }  if ((covariance = QccMatrixAlloc(num_bands, num_bands)) == NULL)    {      QccErrorAddMessage("(QccHYPkltTrain): Error calling QccMatrixAlloc()");      goto Error;    }  if (QccHYPkltCovariance(image, klt->mean, covariance))    {      QccErrorAddMessage("(QccHYPkltTrain): Error calling QccHYPkltCovariance()");      goto Error;    }  if (QccMatrixSVD(covariance,                   num_bands,                   num_bands,                   klt->matrix,                   NULL,                   NULL))    {      QccErrorAddMessage("(QccHYPkltTrain): Error calling QccMatrixSVD()");      goto Error;    }    return_value = 0;  goto Return; Error:  return_value = 1; Return:  QccMatrixFree(covariance, num_bands);  return(return_value);}int QccHYPkltTransform(QccIMGImageCube *image,                       const QccHYPklt *klt,                       int num_pcs){  int return_value;  int num_bands;  int band;  int row, col;  QccVector pixel_vector1 = NULL;  QccVector pixel_vector2 = NULL;  QccMatrix transform_matrix = NULL;  if (image == NULL)    return(0);  if (klt == NULL)    return(0);  if (num_pcs <= 0)    return(0);  num_bands = image->num_frames;    if (klt->num_bands != num_bands)    {      QccErrorAddMessage("(QccHYPkltTransform): Number of bands in KLT (%d) does not match that of image cube (%d)",                         klt->num_bands,                         num_bands);      goto Error;    }  if (num_pcs > num_bands)    {      QccErrorAddMessage("(QccHYPkltTransform): Number of PCs greater than number of bands");      goto Error;    }  if ((pixel_vector1 = QccVectorAlloc(num_bands)) == NULL)    {      QccErrorAddMessage("(QccHYPkltTransform): Error calling QccVectorAlloc()");      goto Error;    }  if ((pixel_vector2 = QccVectorAlloc(num_bands)) == NULL)    {      QccErrorAddMessage("(QccHYPkltTransform): Error calling QccVectorAlloc()");      goto Error;    }  if ((transform_matrix = QccMatrixAlloc(num_bands, num_bands)) == NULL)    {      QccErrorAddMessage("(QccHYPkltTransform): Error calling QccMatrixAlloc()");      goto Error;    }  if (QccMatrixTranspose(klt->matrix,                         transform_matrix,                         num_bands,                         num_bands))    {      QccErrorAddMessage("(QccHYPkltTransform): Error calling QccMatrixTranspose()");      goto Error;    }  for (row = 0; row < image->num_rows; row++)    for (col = 0; col < image->num_cols; col++)      {        for (band = 0; band < num_bands; band++)          pixel_vector1[band] =             image->volume[band][row][col] - klt->mean[band];        if (QccMatrixVectorMultiply(transform_matrix,                                    pixel_vector1,                                    pixel_vector2,                                    num_bands,                                    num_bands))          {            QccErrorAddMessage("(QccHYPkltTransform): Error calling QccMatrixVectorMultiply()");            goto Error;          }        for (band = 0; band < num_bands; band++)          image->volume[band][row][col] = pixel_vector2[band];      }  if (num_pcs != num_bands)    if (QccIMGImageCubeResize(image,                              num_pcs,                              image->num_rows,                              image->num_cols))      {        QccErrorAddMessage("(QccHYPkltTransform): Error calling QccIMGImageCubeResize()");        goto Error;      }  QccIMGImageCubeSetMaxMin(image);  return_value = 0;  goto Return; Error:  return_value = 1; Return:  QccVectorFree(pixel_vector1);  QccVectorFree(pixel_vector2);  QccMatrixFree(transform_matrix, num_bands);  return(return_value);}int QccHYPkltInverseTransform(QccIMGImageCube *image,                              const QccHYPklt *klt){  int return_value;  int num_bands;  int band;  int row, col;  QccVector pixel_vector1 = NULL;  QccVector pixel_vector2 = NULL;  if (image == NULL)    return(0);  if (klt == NULL)    return(0);  num_bands = klt->num_bands;    if (num_bands < image->num_frames)    {      QccErrorAddMessage("(QccHYPkltInverseTransform): Image cube has too many bands for KLT");      goto Error;    }  if (num_bands != image->num_frames)    if (QccIMGImageCubeResize(image,                              num_bands,                              image->num_rows,                              image->num_cols))    {      QccErrorAddMessage("(QccHYPkltInverseTransform): Error calling QccIMGImageCubeResize()");      goto Error;    }  if ((pixel_vector1 = QccVectorAlloc(num_bands)) == NULL)    {      QccErrorAddMessage("(QccHYPkltInverseTransform): Error calling QccVectorAlloc()");      goto Error;    }  if ((pixel_vector2 = QccVectorAlloc(num_bands)) == NULL)    {      QccErrorAddMessage("(QccHYPkltInverseTransform): Error calling QccVectorAlloc()");      goto Error;    }  for (row = 0; row < image->num_rows; row++)    for (col = 0; col < image->num_cols; col++)      {        for (band = 0; band < num_bands; band++)          pixel_vector1[band] = image->volume[band][row][col];        if (QccMatrixVectorMultiply(klt->matrix,                                    pixel_vector1,                                    pixel_vector2,                                    num_bands,                                    num_bands))          {            QccErrorAddMessage("(QccHYPkltInverseTransform): Error calling QccMatrixVectorMultiply()");            goto Error;          }        for (band = 0; band < num_bands; band++)          image->volume[band][row][col] =            pixel_vector2[band] + klt->mean[band];      }  QccIMGImageCubeSetMaxMin(image);  return_value = 0;  goto Return; Error:  return_value = 1; Return:  QccVectorFree(pixel_vector1);  QccVectorFree(pixel_vector2);  return(return_value);}

⌨️ 快捷键说明

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