📄 bisk3d.c
字号:
} current_set_node = current_set_node->next; } return(0);}int QccWAVbisk3DEncodeHeader(QccBitBuffer *output_buffer, int transform_type, int temporal_num_levels, int spatial_num_levels, int num_frames, int num_rows, int num_cols, double image_mean, int max_coefficient_bits){ int return_value; if (QccBitBufferPutBit(output_buffer, transform_type)) { QccErrorAddMessage("(QccWAVbisk3DEncodeHeader): Error calling QccBitBufferPutBit()"); goto Error; } if (transform_type == QCCWAVSUBBANDPYRAMID3D_PACKET) { if (QccBitBufferPutChar(output_buffer, (unsigned char)temporal_num_levels)) { QccErrorAddMessage("(QccWAVbisk3DEncodeHeader): Error calling QccBitBufferPuChar()"); goto Error; } } if (QccBitBufferPutChar(output_buffer, (unsigned char)spatial_num_levels)) { QccErrorAddMessage("(QccWAVbisk3DEncodeHeader): Error calling QccBitBufferPuChar()"); goto Error; } if (QccBitBufferPutInt(output_buffer, num_frames)) { QccErrorAddMessage("(QccWAVbisk3DEncodeHeader): Error calling QccBitBufferPutInt()"); goto Error; } if (QccBitBufferPutInt(output_buffer, num_rows)) { QccErrorAddMessage("(QccWAVbisk3DEncodeHeader): Error calling QccBitBufferPutInt()"); goto Error; } if (QccBitBufferPutInt(output_buffer, num_cols)) { QccErrorAddMessage("(QccWAVbisk3DEncodeHeader): Error calling QccBitBufferPutInt()"); goto Error; } if (QccBitBufferPutDouble(output_buffer, image_mean)) { QccErrorAddMessage("(QccWAVbisk3DEncodeHeader): Error calling QccBitBufferPutDouble()"); goto Error; } if (QccBitBufferPutInt(output_buffer, max_coefficient_bits)) { QccErrorAddMessage("(QccWAVbisk3DEncodeHeader): Error calling QccBitBufferPutInt()"); goto Error; } return_value = 0; goto Return; Error: return_value = 1; Return: return(return_value);}static int QccWAVbisk3DEncodeExtractSigns(QccWAVSubbandPyramid3D *image_subband_pyramid, QccWAVSubbandPyramid3D *mask_subband_pyramid, unsigned char ***state_array, int *max_coefficient_bits){ double coefficient_magnitude; double max_coefficient = -MAXFLOAT; int frame, row, col; if (mask_subband_pyramid == NULL) for (frame = 0; frame < image_subband_pyramid->num_frames; frame++) for (row = 0; row < image_subband_pyramid->num_rows; row++) for (col = 0; col < image_subband_pyramid->num_cols; col++) { coefficient_magnitude = fabs(image_subband_pyramid->volume[frame][row][col]); if (image_subband_pyramid->volume[frame][row][col] != coefficient_magnitude) { image_subband_pyramid->volume[frame][row][col] = coefficient_magnitude; QccWAVbisk3DPutSign(&state_array[frame][row][col], QCCBISK3D_NEGATIVE); } else QccWAVbisk3DPutSign(&state_array[frame][row][col], QCCBISK3D_POSITIVE); if (coefficient_magnitude > max_coefficient) max_coefficient = coefficient_magnitude; } else for (frame = 0; frame < image_subband_pyramid->num_frames; frame++) for (row = 0; row < image_subband_pyramid->num_rows; row++) for (col = 0; col < image_subband_pyramid->num_cols; col++) if (!QccAlphaTransparent(mask_subband_pyramid->volume [frame][row][col])) { coefficient_magnitude = fabs(image_subband_pyramid->volume[frame][row][col]); if (image_subband_pyramid->volume[frame][row][col] != coefficient_magnitude) { image_subband_pyramid->volume[frame][row][col] = coefficient_magnitude; QccWAVbisk3DPutSign(&state_array[frame][row][col], QCCBISK3D_NEGATIVE); } else QccWAVbisk3DPutSign(&state_array[frame][row][col], QCCBISK3D_POSITIVE); if (coefficient_magnitude > max_coefficient) max_coefficient = coefficient_magnitude; } *max_coefficient_bits = (int)floor(QccMathLog2(max_coefficient)); return(0);}static int QccWAVbisk3DDecodeApplySigns(QccWAVSubbandPyramid3D *image_subband_pyramid, QccWAVSubbandPyramid3D *mask_subband_pyramid, unsigned char ***state_array){ int frame, row, col; if (mask_subband_pyramid == NULL) { for (frame = 0; frame < image_subband_pyramid->num_frames; frame++) for (row = 0; row < image_subband_pyramid->num_rows; row++) for (col = 0; col < image_subband_pyramid->num_cols; col++) if (QccWAVbisk3DGetSign(state_array[frame][row][col]) == QCCBISK3D_NEGATIVE) image_subband_pyramid->volume[frame][row][col] *= -1; } else for (frame = 0; frame < image_subband_pyramid->num_frames; frame++) for (row = 0; row < image_subband_pyramid->num_rows; row++) for (col = 0; col < image_subband_pyramid->num_cols; col++) if ((!QccAlphaTransparent(mask_subband_pyramid->volume [frame][row][col])) && (QccWAVbisk3DGetSign(state_array[frame][row][col]) == QCCBISK3D_NEGATIVE)) image_subband_pyramid->volume[frame][row][col] *= -1; return(0);}static int QccWAVbisk3DEncodeDWT(QccWAVSubbandPyramid3D *image_subband_pyramid, const QccIMGImageCube *image_cube, int transform_type, int temporal_num_levels, int spatial_num_levels, double *image_mean, QccWAVSubbandPyramid3D *mask_subband_pyramid, const QccIMGImageCube *mask, const QccWAVWavelet *wavelet){ int frame, row, col; if (mask == NULL) { if (QccVolumeCopy(image_subband_pyramid->volume, image_cube->volume, image_cube->num_frames, image_cube->num_rows, image_cube->num_cols)) { QccErrorAddMessage("(QccWAVbisk3DEncodeDWT): Error calling QccVolumeCopy()"); return(1); } if (QccWAVSubbandPyramid3DSubtractMean(image_subband_pyramid, image_mean, NULL)) { QccErrorAddMessage("(QccWAVbisk3DEncodeDWT): Error calling QccWAVSubbandPyramid3DSubtractMean()"); return(1); } } else { if (QccVolumeCopy(mask_subband_pyramid->volume, mask->volume, mask->num_frames, mask->num_rows, mask->num_cols)) { QccErrorAddMessage("(QccWAVbisk3DEncodeDWT): Error calling QccVolumeCopy()"); return(1); } *image_mean = QccIMGImageCubeShapeAdaptiveMean(image_cube, mask); for (frame = 0; frame < image_subband_pyramid->num_frames; frame++) for (row = 0; row < image_subband_pyramid->num_rows; row++) for (col = 0; col < image_subband_pyramid->num_cols; col++) if (QccAlphaTransparent(mask_subband_pyramid->volume [frame][row][col])) image_subband_pyramid->volume[frame][row][col] = 0; else image_subband_pyramid->volume[frame][row][col] = image_cube->volume[frame][row][col] - *image_mean; } if (mask != NULL) { if (QccWAVSubbandPyramid3DShapeAdaptiveDWT(image_subband_pyramid, mask_subband_pyramid, transform_type, temporal_num_levels, spatial_num_levels, wavelet)) { QccErrorAddMessage("(QccWAVbisk3DEncodeDWT): Error calling QccWAVSubbandPyramid3DShapeAdaptiveDWT()"); return(1); } } else if (QccWAVSubbandPyramid3DDWT(image_subband_pyramid, transform_type, temporal_num_levels, spatial_num_levels, wavelet)) { QccErrorAddMessage("(QccWAVbisk3DEncodeDWT): Error calling QccWAVSubbandPyramid3DDWT()"); return(1); } return(0);}static int QccWAVbisk3DDecodeInverseDWT(QccWAVSubbandPyramid3D *image_subband_pyramid, QccWAVSubbandPyramid3D *mask_subband_pyramid, QccIMGImageCube *image_cube, double image_mean, const QccWAVWavelet *wavelet){ int frame, row, col; if (mask_subband_pyramid != NULL) { if (QccWAVSubbandPyramid3DInverseShapeAdaptiveDWT(image_subband_pyramid, mask_subband_pyramid, wavelet)) { QccErrorAddMessage("(QccWAVbisk3DDecodeInverseDWT): Error calling QccWAVSubbandPyramid3DInverseShapeAdaptiveDWT()"); return(1); } } else if (QccWAVSubbandPyramid3DInverseDWT(image_subband_pyramid, wavelet)) { QccErrorAddMessage("(QccWAVbisk3DDecodeInverseDWT): Error calling QccWAVSubbandPyramid3DInverseDWT()"); return(1); } if (QccWAVSubbandPyramid3DAddMean(image_subband_pyramid, image_mean)) { QccErrorAddMessage("(QccWAVbisk3DDecodeInverseDWT): Error calling QccWAVSubbandPyramid3DAddMean()"); return(1); } if (mask_subband_pyramid != NULL) for (frame = 0; frame < image_subband_pyramid->num_frames; frame++) for (row = 0; row < image_subband_pyramid->num_rows; row++) for (col = 0; col < image_subband_pyramid->num_cols; col++) if (QccAlphaTransparent(mask_subband_pyramid->volume [frame][row][col])) image_subband_pyramid->volume[frame][row][col] = 0; if (QccVolumeCopy(image_cube->volume, image_subband_pyramid->volume, image_cube->num_frames, image_cube->num_rows, image_cube->num_cols)) { QccErrorAddMessage("(QccWAVbisk3DDecodeInverseDWT): Error calling QccVolumeCopy()"); return(1); } if (QccIMGImageCubeSetMaxMin(image_cube)) { QccErrorAddMessage("(QccWAVbisk3DDecodeInverseDWT): Error calling QccIMGImageCubeSetMaxMin()"); return(1); } return(0);}int QccWAVbisk3DEncode2(QccWAVSubbandPyramid3D *image_subband_pyramid, QccWAVSubbandPyramid3D *mask_subband_pyramid, double image_mean, QccBitBuffer *output_buffer, int target_bit_cnt){ int return_value; QccENTArithmeticModel *model = NULL; unsigned char ***state_array = NULL; int max_coefficient_bits; double threshold; int frame; int row, col; QccList LIS; QccList LSP; int bitplane = 0; if (image_subband_pyramid == NULL) return(0); if (output_buffer == NULL) return(0); QccListInitialize(&LIS); QccListInitialize(&LSP); if ((state_array = (unsigned char ***)malloc(sizeof(unsigned char **) * (image_subband_pyramid->num_frames))) == NULL) { QccErrorAddMessage("(QccWAVbisk3DEncode2): Error allocating memory"); goto Error; } for (frame = 0; frame < image_subband_pyramid->num_frames; frame++) { if ((state_array[frame] = (unsigned char **)malloc(sizeof(unsigned char *) * (image_subband_pyramid->num_rows))) == NULL) { QccErrorAddMessage("(QccWAVbisk3DEncode2): Error allocating memory"); goto Error; } for (row = 0; row < image_subband_pyramid->num_rows; row++) if ((state_array[frame][row] = (unsigned char *)malloc(sizeof(unsigned char) * (image_subband_pyramid->num_cols))) == NULL) { QccErrorAddMessage("(QccWAVbisk3DEncode2): Error allocating memory"); goto Error; } } for (frame = 0; frame < (image_subband_pyramid->num_frames); frame++) for (row = 0; row < (image_subband_pyramid->num_rows); row++) for (col = 0; col < (image_subband_pyramid->num_cols); col++) state_array[frame][row][col] = 0; if (QccWAVbisk3DEncodeExtractSigns(image_subband_pyramid, mask_subband_pyramid, state_array, &max_coefficient_bits)) { QccErrorAddMessage("(QccWAVbisk3DEncode2): Error calling QccWAVbisk3DEncodeExtractSigns()"); goto Error; } if (QccWAVbisk3DEncodeHeader(output_buffer, image_subband_pyramid->transform_type, image_subband_pyramid->temporal_num_levels, image_subband_pyramid->spatial_num_levels,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -