📄 image_lbt.c
字号:
QccErrorAddMessage("(QccIMGImageComponentLBTCreate): Error calling QccIMGImageComponentLBTCreateV()"); goto Error; } if (transform_direction == QCCIMGLBT_POSTFILTER) if (QccMatrixInverse(v_filter, v_filter, M, M)) { QccErrorAddMessage("(QccIMGImageComponentLBTCreate): Error calling QccMatrixInverse()"); goto Error; } for (i = 0; i < f_size; i++) for (j = 0; j < f_size; j++) { if ((i < M) && (j < M)) { if (i == j) bf2[i][j] = 1; } if ((i >= M) && (j >= M)) bf2[i][j] = v_filter[i - M][j - M]; } if (QccMatrixMultiply(bf1, f_size, f_size, bf2, f_size, f_size, temp_P)) { QccErrorAddMessage("(QccIMGImageComponentLBTCreate): Error calling QccMatrixMultiply()"); goto Error; } if (QccMatrixMultiply(temp_P, f_size, f_size, bf1, f_size, f_size, p_filter)) { QccErrorAddMessage("(QccIMGImageComponentLBTCreate): Error calling QccMatrixMultiply()"); goto Error; } for (i = 0; i < f_size; i++) for (j = 0; j < f_size; j++) p_filter[i][j] = p_filter[i][j] * 0.5; return_value = 0; goto Return; Error: return_value = 1; Return: QccMatrixFree(v_filter, M); QccMatrixFree(bf1, f_size); QccMatrixFree(bf2, f_size); QccMatrixFree(temp_P, f_size); return(return_value);} static int QccIMGImageComponentLBTProcess(const QccMatrix input_image, const QccMatrix p_filter, QccMatrix output_image, int num_row, int num_cols, int f_size){ int return_value; int row, col; int i; QccMatrix temp_image = NULL; QccVector temp_vector = NULL; QccVector filter_vector = NULL; if ((temp_image = QccMatrixAlloc(num_row, num_cols)) == NULL) { QccErrorAddMessage("(QccIMGImageComponentLBTProcess): Error calling QccMatrixAlloc()"); goto Error; } if ((temp_vector = QccVectorAlloc(f_size)) == NULL) { QccErrorAddMessage("(QccIMGImageComponentLBTProcess): Error calling QccMatrixAlloc()"); goto Error; } if ((filter_vector = QccVectorAlloc(f_size)) == NULL) { QccErrorAddMessage("(QccIMGImageComponentLBTProcess): Error calling QccMatrixAlloc()"); goto Error; } for (col = 0; col < num_cols; col++) for (row = 0; row < f_size / 2; row++) { temp_image[row][col] = input_image[row][col]; temp_image[num_row - row - 1][col] = input_image[num_row - row - 1][col]; } for (col = 0; col < num_cols; col++) for (row = f_size / 2; row < num_row - (f_size / 2); row += f_size) { for (i = 0; i < f_size; i++) temp_vector[i] = input_image[row + i][col]; if (QccMatrixVectorMultiply(p_filter, temp_vector, filter_vector, f_size, f_size)) { QccErrorAddMessage("(QccIMGImageComponentLBTProcess): Error calling QccMatrixVectorMultiply()"); goto Error; } for (i = 0; i < f_size; i++) temp_image[row + i][col] = filter_vector[i]; } for (row = 0; row < num_row; row++) for (col = 0; col < f_size / 2; col++) { output_image[row][col] = temp_image[row][col]; output_image[row][num_cols - col - 1] = temp_image[row][num_cols - col - 1]; } for (row = 0; row < num_row; row++) for (col = f_size / 2; col < num_cols - (f_size / 2); col += f_size) { for (i = 0; i < f_size; i++) temp_vector[i] = temp_image[row][col + i]; if (QccMatrixVectorMultiply(p_filter, temp_vector, filter_vector, f_size, f_size)) { QccErrorAddMessage("(QccIMGImageComponentLBTProcess): Error calling QccVectorAdd()"); goto Error; } for (i = 0; i < f_size; i++) output_image[row][col + i] = filter_vector[i]; } return_value = 0; goto Return; Error: return_value = 1; Return: QccMatrixFree(temp_image, num_row); QccVectorFree(temp_vector); QccVectorFree(filter_vector); return(0);} int QccIMGImageComponentLBT(const QccIMGImageComponent *image1, QccIMGImageComponent *image2, int overlap_sample, int block_size, double smooth_factor){ int return_value; QccMatrix prefilter = NULL; if (image1 == NULL) return(0); if (image2 == NULL) return(0); if ((image1->num_rows != image2->num_rows) || (image1->num_cols != image2->num_cols)) { QccErrorAddMessage("(QccIMGImageComponentLBT): Images must have the same size"); goto Error; } if ((prefilter = QccMatrixAlloc(block_size, block_size)) == NULL) { QccErrorAddMessage("(QccIMGImageComponentLBT): Error calling QccMatrixAlloc()"); goto Error; } if (QccIMGImageComponentLBTCreateFilter(prefilter, overlap_sample, block_size, smooth_factor, QCCIMGLBT_PREFILTER)) { QccErrorAddMessage("(QccIMGImageComponentLBT): Error calling QccIMGImageComponentLBTCreateFilter()"); goto Error; } if (QccIMGImageComponentLBTProcess(image1->image, prefilter, image2->image, image1->num_rows, image1->num_cols, block_size)) { QccErrorAddMessage("(QccIMGImageComponentLBT): Error calling QccIMGImageComponentLBTProcess()"); goto Error; } if (QccIMGImageComponentDCT(image2, image2, block_size, block_size)) { QccErrorAddMessage("(QccWAVdcttceEncodeDCT): Error calling QccIMGImageComponentDCT()"); goto Error; } return_value = 0; goto Return; Error: return_value = 1; Return: QccMatrixFree(prefilter, block_size); return(return_value);} int QccIMGImageComponentInverseLBT(const QccIMGImageComponent *image1, QccIMGImageComponent *image2, int overlap_sample, int block_size, double smooth_factor){ int return_value; QccMatrix postfilter = NULL; if (image1 == NULL) return(0); if (image2 == NULL) return(0); if ((image1->num_rows != image2->num_rows) || (image1->num_cols != image2->num_cols)) { QccErrorAddMessage("(QccIMGImageComponentInverseLBT): Images must have the same size"); goto Error; } if ((postfilter = QccMatrixAlloc(block_size, block_size)) == NULL) { QccErrorAddMessage("(QccIMGImageComponentInverseLBT): Error calling QccMatrixAlloc()"); goto Error; } if (QccIMGImageComponentInverseDCT(image1, image2, block_size, block_size)) { QccErrorAddMessage("(QccWAVdcttceDecodeInverseLBT): Error calling QccIMGImageComponentInverseDCT()"); goto Error; } if (QccIMGImageComponentLBTCreateFilter(postfilter, overlap_sample, block_size, smooth_factor, QCCIMGLBT_POSTFILTER)) { QccErrorAddMessage("(QccIMGImageComponentInverseLBT): Error calling QccIMGImageComponentLBTCreateFilter()"); goto Error; } if (QccIMGImageComponentLBTProcess(image2->image, postfilter, image2->image, image2->num_rows, image2->num_cols, block_size)) { QccErrorAddMessage("(QccIMGImageComponentInverseLBT): Error calling QccIMGImageComponentLBTProcess()"); goto Error; } return_value = 0; goto Return; Error: return_value = 1; Return: QccMatrixFree(postfilter, block_size); return(return_value);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -