Table of Contents

NAME

QccIMGImageComponentDPCMEncode, QccIMGImageComponentDPCMDecode, QccIMGImageDPCMEncode, QccIMGImageDPCMDecode - DPCM encoding and decoding of images and image components

SYNOPSIS

#include "libQccPack.h"

int QccIMGImageComponentDPCMEncode(const QccIMGImageComponent *image_component, const QccSQScalarQuantizer *quantizer, double out_of_bound_value, int predictor_code, QccIMGImageComponent *difference_image, QccChannel *channel);
int QccIMGImageComponentDPCMDecode(QccChannel *channel, const QccSQScalarQuantizer *quantizer, double out_of_bound_value, int predictor_code, QccIMGImageComponent *image_component);

int QccIMGImageDPCMEncode(const QccIMGImage *image, const QccSQScalarQuantizer *quantizers, const QccVector out_of_bound_values, int predictor_code, QccIMGImage *difference_image, QccChannel *channels);
int QccIMGImageDPCMDecode(QccChannel *channels, const QccSQScalarQuantizer *quantizers, const QccVector out_of_bound_values, int predictor_code, QccIMGImage *image);

DESCRIPTION

QccIMGImageComponentDPCMEncode() and QccIMGImageComponentDPCMDecode() implement differential pulse-code modulation (DPCM) of an image_component. In essence, DPCM encoding consists of making a prediction of the current pixel, subtracting the prediction from the current pixel, and scalar-quantizing the resulting difference value to produce a quantization index. This procedure is repeated in a raster-scan fashion throughout the image. DPCM decoding reverses the procedure by inverse scalar-quantizing the index to produce a reconstructed difference and then adding this reconstructed difference to a prediction to reconstruct the current pixel. See "PREDICTION" below for more detail on the predictors used in the DPCM encoder and decoder.

QccIMGImageComponentDPCMEncode() encodes image_component with DPCM using the predictor specified by predictor_code, quantizing difference values with quantizer, and outputting the resulting quantizer indices to channel. QccChannelNormalize(3) is called if the quantization indices consist of both positive and negative numbers, which is the case unless quantizer->type is QCCSQSCALARQUANTIZER_GENERAL. If difference_image is non-NULL, the image of difference values is returned. channel must be allocated with sufficient storage space to hold all the quantizer indices (i.e., one for each pixel in image_component) prior to calling QccIMGImageComponentDPCMEncode().

QccIMGImageComponentDPCMDecode() decodes the channel produced by QccIMGImageComponentDPCMEncode(), reconstructing image_component. For sane results, predictor_code, out_of_bound_value, and quantizer must be the same as those used by QccIMGImageComponentDPCMEncode(). image_component must be allocated prior to calling QccIMGImageComponentDPCMDecode().

QccIMGImageDPCMEncode() and QccIMGImageDPCMDecode() implement DPCM encoding and decoding, respectively, for image. Essentially, QccIMGImageDPCMEncode() calls QccIMGImageComponentDPCMEncode() for each of the Y, U, and V image components of image. out_of_bound_values is a vector of three values to use in the predictor, quantizers is an array of three quantizers to apply to the prediction residuals, and channels is an array of three channels used to store the quantization indices for each of the three components. Similarly, QccIMGImageDPCMDecode() calls QccIMGImageComponentDPCMDecode() for each of the Y, U, and V image components of image.

PREDICTION

For best performance, it is necessary for the DPCM encoder and decoder to stay synchronized throughout the coding of an image component. Thus, the encoder and decoder must use exactly the same predictions. Consequently, both the encoder and decoder calculate a prediction of the current pixel based on previously encoded and reconstructed pixels in the causal neighborhood surrounding the current pixel in the raster scan.

Jain identifies six linear predictors as being particularly useful for image coding. These predictors use four pixels A, B, C, and D in the causal neighborhood surrounding current pixel X as illustrated below.

previous line ... * * * B C D * * * ... current line ... * * * A X - - - - ... next line ... - - - - - - - - - ...

*: previously encoded pixels -: pixels not yet encoded A, B, C, D: previously encoded pixels used by predictor X: current pixel (to be predicted)

The different predictors, specified by predictor_code in these routines, are as follows, where P is the predicted value of the current pixel, X.

Predictor code: 0
P = A
Predictor code: 1
P = (A + D) / 2
Predictor code: 2
P = (A + C) / 2
Predictor code: 3
P = ((A + (C + D)/2) / 2)
Predictor code: 4
P = A + (C - B)
Predictor code: 5
P = A + (D - B)/2

In the event that the current pixel is close to the boundaries of the image component, one or more of the A, B, C, or D pixels may not be available for these predictors. In this case, the predictor substitutes out_of_bound_value for the missing pixel in the prediction formula.

RETURN VALUE

These routines return 0 on success, 1 on failure.

SEE ALSO

QccSQScalarQuantization(3) , QccChannelNormalize(3) , QccIMGImageComponent(3) , QccIMGImage(3) , QccChannel(3) , QccPackIMG(3) , QccPack(3)

A. K. Jain, Fundamentals of Digital Image Processing. Englewood Cliffs, NJ: Prentice Hall, 1989.

AUTHOR

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



Get QccPack at SourceForge.net. Fast, secure and Free Open Source software downloads