⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writing image files.htm

📁 是一部关于java高级图像处理的的一本入门书
💻 HTM
📖 第 1 页 / 共 5 页
字号:
  Files</H2></A>The JPEG standard was developed by a working group, known as the 
  Joint Photographic Experts Group (JPEG). The JPEG image data compression 
  standard handles grayscale and color images of varying resolution and size. 
  <P>JPEG compression identifies and discards "extra" data that is beyond what 
  the human eye can see. Since it discards data, the JPEG compression algorithm 
  is considered "lossy." This means that once an image has been compressed and 
  then decompressed, it will not be identical to the original image. In most 
  cases, the difference between the original and compressed version of the image 
  is indistinguishable. 
  <P>An advantage of JPEG compression is the ability to select the quality when 
  compressing the image. The lower the quality, the smaller the image file size, 
  but the more different it will appear than the original. 
  <P><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#57422">Table 
  13-2</A> lists the JPEG encode parameters that may be set and the default 
  values. The remaining sections describe these settings and how to change them.
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B><A name=57422><I>Table 13-2 </I><IMG 
    src="Writing Image Files.files/sm-blank.gif" border=0> JPEG Encode 
    Parameters </A></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=57428>Parameter </A>
      <TH><A name=57430>Description </A>
      <TH><A name=57432>Default Value </A>
    <TR vAlign=top>
      <TD><A name=58085>writeJFIFHeader</A><BR>
      <TD><A name=58087>Controls whether the encoder writes a JFIF header 
        using the APP0 marker. See <A 
        href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#57417">Section 
        13.5.1, "JFIF Header</A>."</A><BR>
      <TD><A name=58092>True</A><BR>
    <TR vAlign=top>
      <TD><A name=58098>qTabSlot[0],[1],[2]</A><BR>
      <TD><A name=58102>Quantization tables. See <A 
        href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#51433">Section 
        13.5.3, "Quantization Table</A>."</A><BR>
      <TD><A name=58105>0 for Y channel, 1 for Cb and Cr channels</A><BR>
    <TR vAlign=top>
      <TD><A name=58107>qTab[0],[1],[2]</A><BR>
      <TD><A name=58111>Quantization table contents. See <A 
        href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#51433">Section 
        13.5.3, "Quantization Table</A>."</A><BR>
      <TD><A name=58114>Null for all three channels</A><BR>
    <TR vAlign=top>
      <TD><A name=58116>qTabSet[0],[1],[2]</A><BR>
      <TD><A name=58120>Quantization table usage. See <A 
        href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#51433">Section 
        13.5.3, "Quantization Table</A>."</A><BR>
      <TD><A name=58123>False for all three channels</A><BR>
    <TR vAlign=top>
      <TD><A name=57434>hSamp[0],[1],[2]</A><BR>
      <TD><A name=57436>Horizontal subsampling. See <A 
        href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#51546">Section 
        13.5.4, "Horizontal and Vertical Subsampling</A>."</A><BR>
      <TD><A name=57438>1 for Y channel, 2 for Cb and Cr channels</A><BR>
    <TR vAlign=top>
      <TD><A name=57440>vSamp[0],[1],[2]</A><BR>
      <TD><A name=57574>Vertical subsampling. See <A 
        href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#51546">Section 
        13.5.4, "Horizontal and Vertical Subsampling</A>."</A><BR>
      <TD><A name=57528>1 for Y channel, 2 for Cb and Cr channels</A><BR>
    <TR vAlign=top>
      <TD><A name=57464>qual</A><BR>
      <TD><A name=57466>Quality setting. See <A 
        href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#51700">Section 
        13.5.5, "Compression Quality</A>."</A><BR>
      <TD><A name=57468>0.75F</A><BR>
    <TR vAlign=top>
      <TD><A name=57470>rstInterval</A><BR>
      <TD><A name=57472>Restart interval. <A 
        href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#57621">Section 
        13.5.6, "Restart Interval</A>."</A><BR>
      <TD><A name=57474>0</A><BR>
    <TR vAlign=top>
      <TD><A name=57476>writeImageOnly</A><BR>
      <TD><A name=57478>Controls whether encoder writes only the compressed 
        image data. See <A 
        href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#56121">Section 
        13.5.7, "Writing an Abbreviated JPEG Stream</A>."</A><BR>
      <TD><A name=57480>False</A><BR></TR></TBODY></TABLE>
  <P><A name=57417>
  <H3>13.5.1 <IMG src="Writing Image Files.files/space.gif">JFIF 
  Header</H3></A>The JPEG File Interchange Format (JFIF) is a minimal file 
  format that enables JPEG bitstreams to be exchanged between a wide variety of 
  platforms and applications. This minimal format does not include any of the 
  advanced features found in the TIFF JPEG specification or any 
  application-specific file format. The sole purpose of this simplified format 
  is to allow the exchange of JPEG compressed images. 
  <P>The JFIF features are: 
  <P>
  <UL>
    <LI>Uses the JPEG baseline image compression algorithm
    <P></P></LI></UL>
  <UL>
    <LI>Uses JPEG interchange format compressed image representation
    <P></P></LI></UL>
  <UL>
    <LI>Compatible with most platforms (PC, Mac, or Unix)
    <P></P></LI></UL>
  <UL>
    <LI>Standard color space: one or three components. For three components, 
    YC<SUB>b</SUB>C<SUB>r</SUB> (CCIR 601-256 levels)
    <P></P></LI></UL>An APP0 marker is used to identify a JFIF file. The marker 
  provides information that is missing from the JPEG stream, such as version 
  number, <EM>x</EM> and <EM>y</EM> pixel density (dots per inch or dots per 
  cm.), pixel aspect ratio (derived from <EM>x</EM> and <EM>y</EM> pixel 
  density), and thumbnail. The <CODE>setWriteJFIFHeader</CODE> method controls 
  whether the encoder writes a JFIF header using the APP0 marker.<CODE></CODE> 
  <P>
  <TABLE border=0>
    <TBODY>
    <TR>
      <TD><IMG src="Writing Image Files.files/cistine.gif"></TD>
      <TD>
        <HR>
        <B>API:</B> <CODE>com.sun.media.jai.codec.JPEGEncodeParam </CODE>
        <HR>
      </TD></TR></TBODY></TABLE><PRE><UL>
<LI>void setWriteJFIFHeader(boolean writeJFIF)
<P></P></LI></UL></PRE>
  <DL><A name=56204>
    <DT>
    <DD>controls whether the encoder writes a JFIF header using the APP0 marker. 
    By default an APP0 marker is written to create a JFIF file.
    <P>
    <TABLE cellPadding=3 border=3>
      <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
      <TBODY>
      <TR vAlign=top>
        <TD><EM>Parameter</EM>:<EM></EM> 
          <P></P>
        <TD><CODE>writeJFIF</CODE> 
          <P></P>
        <TD>If true, writes a JFIF header. 
          <P></P></TR></TBODY></TABLE></A>
    <P></P></DD></DL><A name=51386>
  <H3>13.5.2 <IMG src="Writing Image Files.files/space.gif">JPEG DCT Compression 
  Parameters</H3></A>JAI uses the JPEG baseline DCT coding process, shown in <A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html#51423">Figure 
  13-1</A>. 
  <P><A name=51421>
  <HR>

  <CENTER><IMG src="Writing Image Files.files/Encode.doc.anc.gif"></CENTER>
  <HR>
  </A><A name=51423>
  <CENTER><FONT size=-1><B><I>Figure 13-1 </I><IMG 
  src="Writing Image Files.files/sm-blank.gif" border=0> JPEG Baseline DCT 
  Coding</B></FONT></CENTER></A>
  <P>For encoding, the image array is divided into 8 x 8 pixel blocks and a 
  discrete cosine transform (DCT) is taken of each block, resulting in an 8 x 
  8array of transform coefficients. The DCT is a mathematical operation that 
  takes the block of image samples as its input and converts the information 
  from the spatial domain to the frequency domain. The 8 x 8 matrix input to the 
  DCT represents brightness levels at specific <EM>x</EM>, <EM>y</EM> 
  coordinates. The resulting 8 x 8 matrix values represent relative amounts of 
  64 spatial frequencies that make up the spectrum of the input data. 
  <P>The next stage in the encoder quantizes the transform coefficients by 
  dividing each DCT coefficient by a value from a quantization table. The 
  quantization operation discards the smaller-valued frequency components, 
  leaving only the larger-valued components. 
  <P>After an image block has been quantized, it enters the entropy encoder, 
  which creates the actual JPEG bitstream. The entropy encoder assigns a binary 
  Huffman code to coefficient values. The length of each code is chosen to be 
  inversely proportional to the expected probability of occurrence of a 
  coefficient amplitude - frequently-occurring coefficient values get short code 
  words, seldom-occurring coefficient values get long code words. The entropy 
  encoder uses two tables, one for the AC frequency components and one for the 
  DC frequency components. 
  <P>The JPEG decoding process is essentially the inverse of the encoding 
  process. The compressed image array data stream passes through the entropy 
  encoder, which recreates the quantized coefficient values. Then, the quantized 
  coefficients are reconstructed by multiplication with the quantizer table 
  values. Finally, an inverse DCT is performed and the reconstructed image array 
  is produced. 
  <P>The following are the parameters that may be specified for JPEG DCT 
  compression. 
  <P><A name=51433>
  <H3>13.5.3 <IMG src="Writing Image Files.files/space.gif">Quantization 
  Table</H3></A>The <CODE>setQTable</CODE> and <CODE>getQTable</CODE> methods 
  are used to specify and retrieve the quantization table that will be used in 
  encoding a particular band of the image. There are, by default, two quantizer 
  tables:
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=51439>Table </A>
      <TH><A name=51441>Band </A>
    <TR vAlign=top>
      <TD><A name=51443>0</A><BR>
      <TD><A name=51445>Band 0</A><BR>
    <TR vAlign=top>
      <TD><A name=51447>1</A><BR>
      <TD><A name=51449>All other bands</A><BR></TR></TBODY></TABLE>
  <P>The parameter <CODE>tableNum</CODE> is usually a value between 0 and 3. 
  This value indicates which of four quantization tables you are specifying. 
  Table 0 is designed to be used with the luminance band of eight-bit YCC 
  images. Table 1 is designed to be used with the chrominance bands of eight-bit 
  YCC images. The two tables can also be set individually using the 
  <CODE>setLumaQTable</CODE> (table 0) and <CODE>setChromaQTable</CODE> (table 
  1) methods. Tables 2 and 3 are not normally used. 
  <P>
  <TABLE border=0>
    <TBODY>
    <TR>
      <TD><IMG src="Writing Image Files.files/cistine.gif"></TD>
      <TD>
        <HR>
        <B>API:</B> <CODE>com.sun.media.jai.codec.JPEGEncodeParam </CODE>
        <HR>
      </TD></TR></TBODY></TABLE><PRE><UL>
<LI>void setQTable(int component, int tableNum, int[] qTable)
<P></P></LI></UL></PRE>
  <DL><A name=51453>
    <DT>
    <DD>sets a quantization table to be used for a component. This method allows 
    up to four independent tables to be specified. This disables any quality 
    setting.
    <P>
    <TABLE cellPadding=3 border=3>
      <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
      <TBODY>
      <TR vAlign=top>
        <TD rowSpan=3><EM>Parameters</EM>:<EM></EM> 
          <P></P>
        <TD><CODE>component</CODE> 
          <P></P>
        <TD>The band to which this table applies. 
          <P></P>
      <TR vAlign=top>
        <TD><CODE>tableNum</CODE> 
          <P></P>
        <TD>The table number that this table is assigned to (0 to 3). 
          <P></P>
      <TR vAlign=top>
        <TD><CODE>qTable</CODE> 
          <P></P>
        <TD>Quantization table values in "zig-zag" order. 
          <P></P></TR></TBODY></TABLE></A>
    <P></P></DD></DL><PRE><UL>
<LI>int[] getQTable(int component)
<P></P></LI></UL></PRE>
  <DL><A name=51455>
    <DT>
    <DD>returns the contents of the quantization table used for a component. If 
    this method is called before the quantization table is set, an error is 
    thrown. </A>
    <P></P></DD></DL><PRE><UL>
<LI>void setLumaQTable(int[] qTable)
<P></P></LI></UL></PRE>
  <DL><A name=56709>
    <DT>
    <DD>sets the quantization table to be used for luminance data. This is a 
    convenience method that explicitly sets the contents of quantization table 
    0. The length of the table must be 64. This disables any quality setting. 
    </A>
    <P></P></DD></DL><PRE><UL>
<LI>void setChromaQTable(int[] qTable)
<P></P></LI></UL></PRE>
  <DL><A name=56718>
    <DT>
    <DD>sets the quantization table to be used for luminance data. This is a 
    convenience method that explicitly sets the contents of quantization table 
    0. The length of the table must be 64. This method assumes that all chroma 
    components will use the same table. This disables any quality setting. </A>
    <P></P></DD></DL><PRE><UL>
<LI>int getQTableSlot(int component)
<P></P></LI></UL></PRE>
  <DL><A name=58061>
    <DT>
    <DD>returns the quantization table slot used for a component. If this method 
    is called before the quantization table data is set, an error is thrown. 
</A>
    <P></P></DD></DL><A name=51546>
  <H3>13.5.4 <IMG src="Writing Image Files.files/space.gif">Horizontal and 
  Vertical Subsampling</H3></A>JPEG allows the image components to be subsampled 
  to reduce their resolution prior to encoding. This is typically done with YCC 
  images, where the two chroma components can be subsampled, usually by a factor 
  of two in both axes. This is possible due to the human visual system's low 
  sensitivity to color images relative to luminance (Y) errors By default, the 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -