📄 subband_pyramid.c
字号:
return(0);}int QccWAVSubbandPyramidAddMean(QccWAVSubbandPyramid *subband_pyramid, double mean){ int subband_row, subband_col; int subband_num_rows, subband_num_cols; if (subband_pyramid == NULL) return(0); if (subband_pyramid->matrix == NULL) return(0); if (subband_pyramid->num_levels != 0) { QccErrorAddMessage("(QccWAVSubbandPyramidAddMean): Subband-pyramid number of levels is not zero"); return(1); } if (QccWAVSubbandPyramidSubbandSize(subband_pyramid, 0, &subband_num_rows, &subband_num_cols)) { QccErrorAddMessage("(QccWAVSubbandPyramidAddMean): Error calling QccWAVSubbandPyramidSubbandSize()"); return(1); } for (subband_row = 0; subband_row < subband_num_rows; subband_row++) for (subband_col = 0; subband_col < subband_num_cols; subband_col++) subband_pyramid->matrix[subband_row][subband_col] += mean; return(0);}int QccWAVSubbandPyramidCalcCoefficientRange(const QccWAVSubbandPyramid *subband_pyramid, const QccWAVWavelet *wavelet, int level, double *max_value, double *min_value){ double mean; double sum = 0; int index; double matrix_max; double matrix_min; if (subband_pyramid == NULL) return(0); if (subband_pyramid->matrix == NULL) return(0); if (wavelet == NULL) return(0); if (wavelet->implementation != QCCWAVWAVELET_IMPLEMENTATION_FILTERBANK) { QccErrorAddMessage("(QccWAVSubbandPyramidCalcCoefficientRange): Wavelet must be of filter-bank implementation"); return(1); } mean = QccMatrixMean(subband_pyramid->matrix, subband_pyramid->num_rows, subband_pyramid->num_cols); for (index = 0; index < wavelet->filter_bank.lowpass_analysis_filter.length; index++) sum += fabs(wavelet->filter_bank.lowpass_analysis_filter.coefficients[index]); matrix_max = QccMatrixMaxValue(subband_pyramid->matrix, subband_pyramid->num_rows, subband_pyramid->num_cols); matrix_min = QccMatrixMaxValue(subband_pyramid->matrix, subband_pyramid->num_rows, subband_pyramid->num_cols); if (max_value != NULL) *max_value = (matrix_max - mean) * pow(sum, (double)level); if (min_value != NULL) *min_value = (matrix_min - mean) * pow(sum, (double)level); return(0);}int QccWAVSubbandPyramidAddNoiseSquare(QccWAVSubbandPyramid *subband_pyramid, int subband, double start, double width, double noise_variance){ int return_value; int subband_num_cols; int subband_num_rows; int subband_row_offset; int subband_col_offset; if (subband_pyramid == NULL) return(0); if (QccWAVSubbandPyramidSubbandSize(subband_pyramid, subband, &subband_num_rows, &subband_num_cols)) { QccErrorAddMessage("(QccWAVSubbandPyramidAddNoiseSquare): Error calling QccWAVSubbandPyramidSubbandSize()"); goto Error; } if (QccWAVSubbandPyramidSubbandOffsets(subband_pyramid, subband, &subband_row_offset, &subband_col_offset)) { QccErrorAddMessage("(QccWAVSubbandPyramidAddNoiseSquare): Error calling QccWAVSubbandPyramidSubbandSize()"); goto Error; } if (QccMatrixAddNoiseToRegion(subband_pyramid->matrix, subband_pyramid->num_rows, subband_pyramid->num_cols, start * subband_num_rows + subband_row_offset, start * subband_num_cols + subband_col_offset, width * subband_num_rows, width * subband_num_cols, noise_variance)) { QccErrorAddMessage("(QccWAVSubbandPyramidAddNoiseSquare): Error calling QccMatrixAddNoiseToRegion()"); goto Error; } return_value = 0; goto Return; Error: return_value = 1; Return: return(return_value);}int QccWAVSubbandPyramidSplitToImageComponent(const QccWAVSubbandPyramid *subband_pyramid, QccIMGImageComponent *output_images){ int num_subbands; int subband; int subband_num_rows, subband_num_cols; int subband_row_offset, subband_col_offset; int row, col; if ((subband_pyramid == NULL) || (output_images == NULL)) return(0); num_subbands = QccWAVSubbandPyramidNumLevelsToNumSubbands(subband_pyramid->num_levels); for (subband = 0; subband < num_subbands; subband++) { if (QccWAVSubbandPyramidSubbandSize(subband_pyramid, subband, &subband_num_rows, &subband_num_cols)) { QccErrorAddMessage("(QccWAVSubbandPyramidSplitToImageComponent): Error calling QccWAVSubbandPyramidSubbandSize()"); return(1); } output_images[subband].num_rows = subband_num_rows; output_images[subband].num_cols = subband_num_cols; if (QccIMGImageComponentAlloc(&(output_images[subband]))) { QccErrorAddMessage("(QccWAVSubbandPyramidSplitToImageComponent): Error calling QccIMGImageComponentAlloc()"); return(1); } if (QccWAVSubbandPyramidSubbandOffsets(subband_pyramid, subband, &subband_row_offset, &subband_col_offset)) { QccErrorAddMessage("(QccWAVSubbandPyramidSplitToImageComponent): Error calling QccWAVSubbandPyramidSubbandOffsets()"); return(1); } for (row = 0; row < subband_num_rows; row++) for (col = 0; col < subband_num_cols; col++) output_images[subband].image[row][col] = subband_pyramid->matrix[subband_row_offset + row] [subband_col_offset + col]; QccIMGImageComponentSetMin(&output_images[subband]); QccIMGImageComponentSetMax(&output_images[subband]); } return(0);}int QccWAVSubbandPyramidSplitToDat(const QccWAVSubbandPyramid *subband_pyramid, QccDataset *output_datasets, const int *vector_dimensions){ int num_subbands; int return_value; int subband; int tile_dimension; QccIMGImageComponent *subband_images = NULL; if (subband_pyramid == NULL) return(0); if (vector_dimensions == NULL) return(0); if (output_datasets == NULL) return(0); num_subbands = QccWAVSubbandPyramidNumLevelsToNumSubbands(subband_pyramid->num_levels); if ((subband_images = (QccIMGImageComponent *) malloc(sizeof(QccIMGImageComponent)*num_subbands)) == NULL) { QccErrorAddMessage("(QccWAVSubbandPyramidSplitToDat): Error allocating memory"); goto Error; } for (subband = 0; subband < num_subbands; subband++) QccIMGImageComponentInitialize(&(subband_images[subband])); if (QccWAVSubbandPyramidSplitToImageComponent(subband_pyramid, subband_images)) { QccErrorAddMessage("(QccWAVsubbandPyramidSplitToDat): Error calling QccWAVSubbandPyramidSplitToImageComponent()"); goto Error; } for (subband = 0; subband < num_subbands; subband++) { tile_dimension = sqrt((double)vector_dimensions[subband]); if (QccIMGImageComponentToDataset(&subband_images[subband], &output_datasets[subband], tile_dimension, tile_dimension)) { QccErrorAddMessage("(QccWAVSubbandPyramidSplitToDat): Error calling QccIMGImageComponentToDat()"); goto Error; } } return_value = 0; goto Return; Error: return_value = 1; Return: if (subband_images != NULL) { for (subband = 0; subband < num_subbands; subband++) QccIMGImageComponentFree(&(subband_images[subband])); QccFree(subband_images); } return(return_value);}int QccWAVSubbandPyramidAssembleFromImageComponent(const QccIMGImageComponent *input_images, QccWAVSubbandPyramid *subband_pyramid){ int num_subbands; int subband; int subband_num_cols, subband_num_rows; int subband_col_offset, subband_row_offset; int row, col; if ((input_images == NULL) || (subband_pyramid == NULL)) return(0); num_subbands = QccWAVSubbandPyramidNumLevelsToNumSubbands(subband_pyramid->num_levels); for (subband = 0; subband < num_subbands; subband++) { if (QccWAVSubbandPyramidSubbandSize(subband_pyramid, subband, &subband_num_rows, &subband_num_cols)) { QccErrorAddMessage("(QccWAVSubbandPyramidAssembleFromImageComponent): Error calling QccWAVSubbandPyramidSubbandSize()"); return(1); } if (QccWAVSubbandPyramidSubbandOffsets(subband_pyramid, subband, &subband_row_offset, &subband_col_offset)) { QccErrorAddMessage("(QccWAVSubbandPyramidAssembleFromImageComponent): Error calling QccWAVSubbandPyramidSubbandOffsets()"); return(1); } for (row = 0; row < subband_num_rows; row++) for (col = 0; col < subband_num_cols; col++) subband_pyramid->matrix[subband_row_offset + row] [subband_col_offset + col] = input_images[subband].image[row][col]; } return(0);}int QccWAVSubbandPyramidAssembleFromDat(const QccDataset *input_datasets, QccWAVSubbandPyramid *subband_pyramid, const int *vector_dimensions){ QccIMGImageComponent *subband_images; int subband; int num_subbands; int return_value; int tile_dimension; int subband_num_rows, subband_num_cols; if ((input_datasets == NULL) || (subband_pyramid == NULL)) return(0); num_subbands = QccWAVSubbandPyramidNumLevelsToNumSubbands(subband_pyramid->num_levels); if ((subband_images = (QccIMGImageComponent *) malloc(sizeof(QccIMGImageComponent)*num_subbands)) == NULL) { QccErrorAddMessage("(QccWAVSubbandPyramidAssembleFromDat): Error allocating memory"); goto Error; } for (subband = 0; subband < num_subbands; subband++) { if (QccWAVSubbandPyramidSubbandSize(subband_pyramid, subband, &subband_num_rows, &subband_num_cols)) { QccErrorAddMessage("(QccWAVSubbandPyramidAssembleFromDat): Error calling QccWAVSubbandPyramidSubbandSize()"); return(1); } QccIMGImageComponentInitialize(&(subband_images[subband])); subband_images[subband].num_rows = subband_num_rows;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -