Saturday, February 21, 2009

JPEG File Interchange Format V1.02 - II

APP0 marker used for application-specific information

Additional APP0 marker segments can be used to hold application-specific information which does not affect the decodability or displayability of the JFIF file. Applicationspecific

APP0 marker segments must appear after the JFIF APP0 and any JFXX APP0
segments. Decoders should skip any unrecognized application-specific APP0 segments.
Application-specific APP0 marker segments are identified by a zero terminated string which identifies the application (not "JFIF" or “JFXX”). This string should be an organization name or company trademark. Generic strings such as dog, cat, tree, etc. should not be used.
Conversion to and from RGB
Y, Cb, and Cr are converted from R, G, and B as defined in CCIR Recommendation 601but are normalized so as to occupy the full 256 levels of a 8-bit binary encoding. Moreprecisely:
Y = 256 * E'y
Cb = 256 * [ E'Cb ] + 128
Cr = 256 * [ E'Cr ] + 128
where the E'y, E'Cb and E'Cb are defined as in CCIR 601. Since values of E'y have arange of 0 to 1.0 and those for E'Cb and E'Cr have a range of -0.5 to +0.5, Y, Cb, andCr must be clamped to 255 when they are maximum value.
RGB to YCbCr Conversion
YCbCr (256 levels) can be computed directly from 8-bit RGB as follows:
Y = 0.299 R + 0.587 G + 0.114
BCb = - 0.1687 R - 0.3313 G + 0.5 B + 128
Cr = 0.5 R - 0.4187 G - 0.0813 B + 128
NOTE - Not all image file formats store image samples in the order R0, G0,B0, ... Rn, Gn, Bn. Be sure to verify the sample order before convertingan RGB file to JFIF.
YCbCr to RGB Conversion
RGB can be computed directly from YCbCr (256 levels) as follows:
R = Y + 1.402 (Cr-128)
G = Y - 0.34414 (Cb-128) - 0.71414 (Cr-128)
B = Y + 1.772 (Cb-128)
Image Orientation
In JFIF files, the image orientation is always top-down. This means that the first imagesamples encoded in a JFIF file are located in the upper left hand corner of the image andencoding proceeds from left to right and top to bottom. Top-down orientation is used forboth the full resolution image and the thumbnail image.
The process of converting an image file having bottom-up orientation to JFIF must includeinverting the order of all image lines before JPEG encoding.
Spatial Relationship of Components
Specification of the spatial positioning of pixel samples within components relative to thesamples of other components is necessary for proper image post processing and accurateimage presentation. In JFIF files, the position of the pixels in subsampled components aredefined with respect to the highest resolution component. Since components must besampled orthogonally (along rows and columns), the spatial position of the samples in agiven subsampled component may be determined by specifying the horizontal and verticaloffsets of the first sample, i.e. the sample in the upper left corner, with respect to thehighest resolution component.
The horizontal and vertical offsets of the first sample in a subsampled component,Xoffseti[0,0] and Yoffseti[0,0], is defined to be
Xoffseti[0,0] = ( Nsamplesref / Nsamplesi ) / 2 - 0.5
Yoffseti[0,0] = ( Nlinesref / Nlinesi ) / 2 - 0.5
where
Nsamplesref is the number of samples per line in the largest component,
Nsamplesi is the number of samples per line in the ith component,
Nlinesref is the number of lines in the largest component,
Nlinesi is the number of lines in the ith component.
Proper subsampling of components incorporates an anti-aliasing filter which reduces thespectral bandwidth of the full resolution components. Subsampling can easily beaccomplished using a symmetrical digital filter with an even number of taps (coefficients).A commonly used filter for 2:1 subsampling utilizes two taps (1/2,1/2).
As an example, consider a 3 component image which is comprised of components havingthe following dimensions:
Component 1: 256 samples, 288 lines
Component 2: 128 samples, 144 lines
Component 3: 64 samples, 96 lines
NOTE - This definition is compatible with industry standards such as PostcriptLevel 2 and QuickTime. This defintition is not compatible with the conventionsused by CCIR Recommendation 601-1 and other digital video formats. For theseformats, pre-processing of the chrominance components is necessary prior tocompression in order to ensure accurate reconstruction of the compressed image.

No comments:

Post a Comment