📄 341-345.html
字号:
<HTML>
<HEAD>
<META name=vsisbn content="1558515682"><META name=vstitle content="Java Digital Signal Processing"><META name=vsauthor content="Douglas A. Lyon"><META name=vsimprint content="M&T Books"><META name=vspublisher content="IDG Books Worldwide, Inc."><META name=vspubdate content="11/01/97"><META name=vscategory content="Web and Software Development: Programming, Scripting, and Markup Languages: Java"><TITLE>Java Digital Signal Processing:Digital Images and Image Formats</TITLE>
<!-- HEADER --><STYLE type="text/css"> <!-- A:hover { color : Red; } --></STYLE><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<!--ISBN=1558515682//-->
<!--TITLE=Java Digital Signal Processing//-->
<!--AUTHOR=Douglas A. Lyon//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=8//-->
<!--PAGES=341-345//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="339-341.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="345-352.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading12"></A><FONT COLOR="#000077">Progressive Display and the Internet</FONT></H4>
<P>For users of the Internet and the World Wide Web, it is useful to enable progressive display of graphics images. When a user arrives at a new Web destination, any graphics data that is loaded for display is shown while it is loading. In this way, the user can immediately recognize the image instead of waiting for the entire image file to load before seeing anything. A few formats support progressive display: JPEG, GIF, and its patent-free successor, PNG. GIF has an option to store graphics data with every eighth line of data, then every fourth line, then every second line, and finally every line, for a total of four passes over the data. You can see a preview of an image with only one-eighth of the data file. This GIF storage option is called the <I>interlaced</I> option. The <I>non-interlaced</I> storage option stores rows sequentially and does not support progressive display (see Figure 8.3).</P>
<P><A NAME="Fig3"></A><A HREF="javascript:displayWindow('images/08-03.jpg',559,608 )"><IMG SRC="images/08-03t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/08-03.jpg',559,608)"><FONT COLOR="#000077"><B>Figure 8.3</B></FONT></A> Interlaced and non-interlaced storage in GIF.</P>
<P>The PNG format goes one up on GIF. PNG has an interlaced format, in which every eighth pixel of every eighth line is first transmitted. An image can be viewed with only 1/64th of the full image data.
</P>
<P>JPEG data streams have an option for progressive display. Instead of scanlines, the image is sent in progressively more-detailed layers. Approximations of the original image are sent in sequence so that the viewer sees the whole image right away; the quality of the image improves with time. Displaying each scan of progressive JPEG takes a full JPEG decompression cycle, and that can be CPU-intensive. Another extension of JPEG provides for hierarchical storage of the same image at multiple resolutions. A complete image is available at different resolutions to match the resolution of the display or print hardware.</P>
<H3><A NAME="Heading13"></A><FONT COLOR="#000077">Details of Several Formats</FONT></H3>
<P>This section discusses in detail certain of the file formats, including those that are used by DiffCAD. Note that the Sun Java AWT class library provides built-in support for reading and writing JPEG and GIF image files. DiffCAD provides wrapper classes for some of this functionality. See the classes <I>WriteGIF</I>, <I>ReadGIF</I> and, <I>VSImage</I>.</P>
<H4 ALIGN="LEFT"><A NAME="Heading14"></A><FONT COLOR="#000077">GIF</FONT></H4>
<P>GIF uses the LZW compressor. There are two versions: GIF87a (the original) and GIF89a. GIF89a may be incompatible with software that reads only GIF87a images, so most modern readers are expected to be able to read both formats. The formats are similar, but GIF89a has further extensions. Figure 8.4 shows the file layout for both formats, highlighting the differences.
</P>
<P><A NAME="Fig4"></A><A HREF="javascript:displayWindow('images/08-04.jpg',402,303 )"><IMG SRC="images/08-04t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/08-04.jpg',402,303)"><FONT COLOR="#000077"><B>Figure 8.4</B></FONT></A> GIF87a (left) and GIF89a file layouts.</P>
<P>The file formats contain several pieces.
</P>
<DL>
<DD><B>•</B> Header. The header is six bytes in size. The first three bytes are “GIF” to identify the format; the next three bytes are the version (“87a” or “89a”).
<DD><B>•</B> Logical screen descriptor. This fixed-size group of bytes contains information about the minimum screen resolution (height and width) and color information to reproduce the image. If the screen is smaller than the screen parameters, the application will need to perform some scaling to display the image.
<DD><B>•</B> Global color table. This optional section contains a CLUT of as many as 256 entries.
<DD><B>•</B> Local image descriptor. This section has characteristics of the ensuing image data, including where on the display the image should start and the image resolution and color information.
<DD><B>•</B> Local color table. GIF can be expanded to include more than one image, although this option is rarely used. A provision is therefore made to include a color table (termed “local”) for each of the images. This is an optional table for specifying a CLUT for the image data that follows. This table, if present, supersedes the global color table.
<DD><B>•</B> Image data. When compressed by LZW, image data usually comes out as a stream of data that must be read from beginning to end. GIF splits the data into a series of subblocks. Each subblock starts with a count byte, which can range from 1 to 255. The count byte value specifies the number of data bytes that will follow. A byte of value zero is used to terminate the subblock.
</DL>
<H4 ALIGN="LEFT"><A NAME="Heading15"></A><FONT COLOR="#000077">JPEG/JFIF</FONT></H4>
<P>The JPEG standard contains ambiguities that make it an incomplete file format standard. C-Cube Microsystems created a file format called JPEG File Interchange Format (JFIF) that fills in the gaps. It is based on the baseline JPEG standard. JPEG is usually best applied to high-resolution, full-color (24-bpp) images, because the transform-based coding will have more latitude for compression with more color information. Keep in mind that sharp edges, such as those created by overlaid text, can become blurry. When compressing with JPEG, an application usually presents a quality setting that trades off compression for quality. To retain high-frequency detail in the source image, you can choose a high quality setting, although it will result in decreased compression. The trade-off between quality and compression is a thorny and persistent issue for JPEG.
</P>
<P>A JPEG encoder uses the following steps:</P>
<DL>
<DD><B>1.</B> Create header information.
<DD><B>2.</B> Read the source image data in RGB.
<DD><B>3.</B> Transform data to YUV color space. Y is black and white intensity information, and the U and V channels have color information. The transformation is linear (see Chapter 9 for color-space conversion).
<DD><B>4.</B> Subsample the U and V channels. Discard any color information that is imperceptible to the viewer; use fewer samples of U and V for every sample of Y.
<DD><B>5.</B> Perform the DCT on the Y, U, and V data.
<DD><B>6.</B> Quantize the resulting coefficients into different bins. This process performs some compression by reducing the number of different possible values; more aggressive quantization is used for the color components.
<DD><B>7.</B> Huffman-encode the quantized data and produce an output data stream.
</DL>
<P>Both a raw JPEG file and a JFIF file start with the bytes 255 and 232 to signify the start-of-image marker. For a JFIF file, you will see the bytes 255 and 240 followed by the characters “JFIF” and information about the image. Data that follows the first block is standard JPEG data as defined by the specification. For detailed information, obtain the specification from the American National Standards Institute [ANSI].
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="339-341.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="345-352.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<hr width="90%" size="1" noshade><div align="center"><font face="Verdana,sans-serif" size="1">Copyright © <a href="/reference/idgbooks00001.html">IDG Books Worldwide, Inc.</a></font></div>
<!-- all of the reference materials (books) have the footer and subfoot reveresed --><!-- reference_subfoot = footer --><!-- reference_footer = subfoot --></BODY></HTML><!-- END FOOTER -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -