📄 spiht3d.c
字号:
} if (transform_type == QCCWAVSUBBANDPYRAMID3D_PACKET) { if (QccBitBufferPutChar(buffer, zerotree_type)) { QccErrorAddMessage("(QccSPIHT3DEncodeHeader): Error calling QccBitBufferPutChar()"); goto Error; } if (QccBitBufferPutChar(buffer, (unsigned char)temporal_num_levels)) { QccErrorAddMessage("(QccSPIHT3DEncodeHeader): Error calling QccBitBufferPuChar()"); goto Error; } } if (QccBitBufferPutChar(buffer, (unsigned char)spatial_num_levels)) { QccErrorAddMessage("(QccSPIHT3DEncodeHeader): Error calling QccBitBufferPuChar()"); goto Error; } if (QccBitBufferPutInt(buffer, num_frames)) { QccErrorAddMessage("(QccSPIHT3DEncodeHeader): Error calling QccBitBufferPutInt()"); goto Error; } if (QccBitBufferPutInt(buffer, num_rows)) { QccErrorAddMessage("(QccSPIHT3DEncodeHeader): Error calling QccBitBufferPutInt()"); goto Error; } if (QccBitBufferPutInt(buffer, num_cols)) { QccErrorAddMessage("(QccSPIHT3DEncodeHeader): Error calling QccBitBufferPutInt()"); goto Error; } if (QccBitBufferPutDouble(buffer, image_mean)) { QccErrorAddMessage("(QccSPIHT3DEncodeHeader): Error calling QccBitBufferPutDouble()"); goto Error; } if (QccBitBufferPutInt(buffer, max_coefficient_bits)) { QccErrorAddMessage("(QccSPIHT3DEncodeHeader): Error calling QccBitBufferPutInt()"); goto Error; } if (QccBitBufferPutBit(buffer, arithmetic_coded)) { QccErrorAddMessage("(QccSPIHT3DEncodeHeader): Error calling QccBitBufferPutBit()"); goto Error; } return_value = 0; goto Return; Error: return_value = 1; Return: return(return_value);}static int QccSPIHT3DEncodeExtractSigns(QccWAVSubbandPyramid3D *image_subband_pyramid, QccWAVSubbandPyramid3D *mask_subband_pyramid, int ***sign_array, int *max_coefficient_bits, int transform_type, int zerotree_type){ double coefficient_magnitude; double max_coefficient = -MAXFLOAT; int frame, row, col; int packet_tree_num_levels; if ((transform_type == QCCWAVSUBBANDPYRAMID3D_PACKET) && (zerotree_type == QCCSPIHT3D_ZEROTREE_PACKET)) { packet_tree_num_levels = QccMathMin(image_subband_pyramid->temporal_num_levels, image_subband_pyramid->spatial_num_levels); if (QccWAVSubbandPyramid3DPacketToDyadic(image_subband_pyramid, packet_tree_num_levels)) { QccErrorAddMessage("(QccSPIHT3DEncodeExtractSigns): Error calling QccWAVSubbandPyramid3DPacketToDyadic()"); return(1); } if (mask_subband_pyramid != NULL) if (QccWAVSubbandPyramid3DPacketToDyadic(mask_subband_pyramid, packet_tree_num_levels)) { QccErrorAddMessage("(QccSPIHT3DEncodeExtractSigns): Error calling QccWAVSubbandPyramid3DPacketToDyadic()"); 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++) { 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; sign_array[frame][row][col] = 1; } else sign_array[frame][row][col] = 0; 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; sign_array[frame][row][col] = 1; } else sign_array[frame][row][col] = 0; if (coefficient_magnitude > max_coefficient) max_coefficient = coefficient_magnitude; } *max_coefficient_bits = (int)floor(QccMathLog2(max_coefficient)); return(0);}static int QccSPIHT3DDecodeApplySigns(QccWAVSubbandPyramid3D *image_subband_pyramid, QccWAVSubbandPyramid3D *mask_subband_pyramid, int ***sign_array, int transform_type, int zerotree_type, int temporal_num_levels, int spatial_num_levels){ 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 (sign_array[frame][row][col]) 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])) && sign_array[frame][row][col]) image_subband_pyramid->volume[frame][row][col] *= -1; if ((transform_type == QCCWAVSUBBANDPYRAMID3D_PACKET) && (zerotree_type == QCCSPIHT3D_ZEROTREE_PACKET)) { if (QccWAVSubbandPyramid3DDyadicToPacket(image_subband_pyramid, temporal_num_levels, spatial_num_levels)) { QccErrorAddMessage("(QccSPIHT3DDecodeApplySigns): Error calling QccWAVSubbandPyramid3DDyadicToPacket()"); return(1); } if (mask_subband_pyramid != NULL) { if (QccWAVSubbandPyramid3DDyadicToPacket(mask_subband_pyramid, temporal_num_levels, spatial_num_levels)) { QccErrorAddMessage("(QccSPIHT3DDecodeApplySigns): Error calling QccWAVSubbandPyramid3DDyadicToPacket()"); return(1); } } } return(0);}static int QccSPIHT3DEncodeDWT(QccWAVSubbandPyramid3D *image_subband_pyramid, const QccIMGImageCube *image, 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->volume, image->num_frames, image->num_rows, image->num_cols)) { QccErrorAddMessage("(QccSPIHT3DEncodeDWT): Error calling QccVolumeCopy()"); return(1); } if (QccWAVSubbandPyramid3DSubtractMean(image_subband_pyramid, image_mean, NULL)) { QccErrorAddMessage("(QccSPIHT3DEncodeDWT): Error calling QccWAVSubbandPyramid3DSubtractMean()"); return(1); } } else { if (QccVolumeCopy(mask_subband_pyramid->volume, mask->volume, mask->num_frames, mask->num_rows, mask->num_cols)) { QccErrorAddMessage("(QccSPIHT3DEncodeDWT): Error calling QccVolumeCopy()"); return(1); } *image_mean = QccIMGImageCubeShapeAdaptiveMean(image, 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->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("(QccSPIHT3DEncodeDWT): Error calling QccWAVSubbandPyramid3DShapeAdaptiveDWT()"); return(1); } } else if (QccWAVSubbandPyramid3DDWT(image_subband_pyramid, transform_type, temporal_num_levels, spatial_num_levels, wavelet)) { QccErrorAddMessage("(QccSPIHT3DEncodeDWT): Error calling QccWAVSubbandPyramid3DDWT()"); return(1); } return(0);}static int QccSPIHT3DDecodeInverseDWT(QccWAVSubbandPyramid3D *image_subband_pyramid, QccWAVSubbandPyramid3D *mask_subband_pyramid, QccIMGImageCube *image, 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("(QccSPIHT3DDecodeInverseDWT): Error calling QccWAVSubbandPyramid3DInverseShapeAdaptiveDWT()"); return(1); } } else if (QccWAVSubbandPyramid3DInverseDWT(image_subband_pyramid, wavelet)) { QccErrorAddMessage("(QccSPIHT3DDecodeInverseDWT): Error calling QccWAVSubbandPyramid3DInverseDWT()"); return(1); } if (QccWAVSubbandPyramid3DAddMean(image_subband_pyramid, image_mean)) { QccErrorAddMessage("(QccSPIHT3DDecodeInverseDWT): 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->volume, image_subband_pyramid->volume, image->num_frames, image->num_rows, image->num_cols)) { QccErrorAddMessage("(QccSPIHT3DDecodeInverseDWT): Error calling QccVolumeCopy()"); return(1); } if (QccIMGImageCubeSetMaxMin(image)) { QccErrorAddMessage("(QccSPIHT3DDecodeInverseDWT): QccError calling QccIMGImageCubeSetMaxMin()"); return(1); } return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -