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

📄 color space.htm

📁 是一部关于java高级图像处理的的一本入门书
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0090)http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Color.doc.html -->
<HTML><HEAD><TITLE>Color Space</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content=reference name=collection>
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<CENTER><A 
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/JAITOC.fm.html"><IMG 
alt=Contents src="Color Space.files/contents.gif"></A> <A 
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Acquisition.doc.html"><IMG 
alt=Previous src="Color Space.files/previous.gif"></A> <A 
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Image-manipulation.doc.html"><IMG 
alt=Next src="Color Space.files/next.gif"></A> 
<P><FONT size=5><I>Programming in Java Advanced Imaging</I></FONT> </CENTER><BR>
<CENTER><A name=47227>
<TABLE width="90%" border=0>
  <TBODY>
  <TR>
    <TD align=right><FONT size=3>C H A P T E R</FONT><FONT size=7><IMG 
      src="Color Space.files/sm-space.gif">5</FONT></TD></TR></TBODY></TABLE></A></CENTER>
<CENTER><A name=47285>
<TABLE width="90%" border=0>
  <TBODY>
  <TR>
    <TD align=right>
      <HR noShade SIZE=7>
      <FONT size=6>Color Space</FONT></TD></TR></TBODY></TABLE></A></CENTER>
<BLOCKQUOTE>
  <P><BR><BR><BR>
  <P><FONT size=7><B>T</B></FONT>HIS chapter describes the JAI color space, 
  transparency, and the color conversion operators. JAI follows the Java AWT 
  color model. 
  <P><A name=51145>
  <H2>5.1 <IMG src="Color Space.files/space.gif">Introduction</H2></A>Digital 
  images, specifically digital color images, come in several different forms. 
  The form is often dictated by the means by which the image was acquired or by 
  the image's intended use. 
  <P>One of the more basic types of color image is RGB, for the three primary 
  colors (red, green, and blue). RGB images are sometimes acquired by a color 
  scanner or video camera. These devices incorporate three sensors that are 
  spectrally sensitive to light in the red, green, and blue portions of the 
  spectrum. The three separate red, green, and blue values can be made to 
  directly drive red, green, and blue light guns in a CRT. This type of color 
  system is called an <EM>additive</EM> linear RGB color system, as the sum of 
  the three full color values produces white. 
  <P>Printed color images are based on a <EM>subtractive</EM> color process in 
  which cyan, magenta, and yellow (CMY) dyes are deposited onto paper. The 
  amount of dye deposited is subtractively proportional to the amount of each 
  red, blue, and green color value. The sum of the three CMY color values 
  produce black. 
  <P>The black produced by a CMY color system often falls short of being a true 
  black. To produce a more accurate black in printed images, black is often 
  added as a fourth color component. This is known as the CMYK color system and 
  is commonly used in the printing industry. 
  <P>The amount of light generated by the red, blue, and green phosphors of a 
  CRT is not linear. To achieve good display quality, the red, blue, and green 
  values must be adjusted - a process known as <EM>gamma correction</EM>. In 
  computer systems, gamma correction often takes place in the frame buffer, 
  where the RGB values are passed through lookup tables that are set with the 
  necessary compensation values. 
  <P>In television transmission systems, the red, blue, and green 
  gamma-corrected color video signals are not transmitted directly. Instead, a 
  linear transformation between the RGB components is performed to produce a 
  <EM>luminance</EM> signal and a pair of <EM>chrominance</EM> signals. The 
  luminance signal conveys color brightness levels. The two chrominance signals 
  convey the color hue and saturation. This color system is called YCC (or, more 
  specifically, YC<SUB>b</SUB>C<SUB>r</SUB>). 
  <P>Another significant color space standard for JAI is CIEXYZ. This is a 
  widely-used, device-independent color standard developed by the Commission 
  Internationale de l'&Eacute;clairage (CIE). The CIEXYZ standard is based on 
  color-matching experiments on human observers. 
  <P><A name=51219>
  <H2>5.2 <IMG src="Color Space.files/space.gif">Color Management</H2></A>JAI 
  uses three primary classes for the management of color: 
  <P>
  <UL>
    <LI><CODE>ColorModel</CODE> - describes a particular way that pixel values 
    are mapped to colors. A <CODE>ColorModel</CODE> is typically associated with 
    an <CODE>Image</CODE> or <CODE>BufferedImage</CODE> and provides the 
    information necessary to correctly interpret pixel values. 
    <CODE>ColorModel</CODE> is defined in the <CODE>java.awt.image</CODE> 
    package.
    <P></P></LI></UL>
  <UL>
    <LI><CODE>ColorSpace</CODE> - represents a system for measuring colors, 
    typically using three separate values or components. The 
    <CODE>ColorSpace</CODE> class contains methods for converting between the 
    original color space and one of two standard color spaces, CIEXYZ and RGB. 
    <CODE>ColorSpace</CODE> is defined in the <CODE>java.awt.color</CODE> 
    package.
    <P></P></LI></UL>
  <UL>
    <LI><CODE>Color</CODE> - a fixed color, defined in terms of its components 
    in a particular <CODE>ColorSpace</CODE>. <CODE>Color</CODE> is defined in 
    the <CODE>java.awt</CODE> package.
    <P></P></LI></UL><A name=51226>
  <H3>5.2.1 <IMG src="Color Space.files/space.gif">Color Models</H3></A>A 
  <CODE>ColorModel</CODE> is used to interpret pixel data in an image. This 
  includes: 
  <P>
  <UL>
    <LI>Mapping components in the bands of an image to components of a 
    particular color space
    <P></P></LI></UL>
  <UL>
    <LI>Extracting pixel components from packed pixel data
    <P></P></LI></UL>
  <UL>
    <LI>Retrieving multiple components from a single band using masks
    <P></P></LI></UL>
  <UL>
    <LI>Converting pixel data through a lookup table
    <P></P></LI></UL>To determine the color value of a particular pixel in an 
  image, you need to know how the color information is encoded in each pixel. 
  The <CODE>ColorModel</CODE> associated with an image encapsulates the data and 
  methods necessary for translating a pixel value to and from its constituent 
  color components. 
  <P>JAI supports five color models: 
  <P>
  <UL>
    <LI><CODE>DirectColorModel</CODE> - works with pixel values that represent 
    RGB color and alpha information as separate samples and that pack all 
    samples for a single pixel into a single int, short, or byte quantity. This 
    class can be used only with ColorSpaces of type 
    <CODE>ColorSpace.TYPE_RGB</CODE>.
    <P></P></LI></UL>
  <UL>
    <LI><CODE>IndexColorModel</CODE> - works with pixel values consisting of a 
    single sample that is an index into a fixed colormap in the default sRGB 
    ColorSpace. The colormap specifies red, green, blue, and optional alpha 
    components corresponding to each index.
    <P></P></LI></UL>
  <UL>
    <LI><CODE>ComponentColorModel</CODE> - can handle an arbitrary 
    <CODE>ColorSpace</CODE> and an array of color components to match the 
    <CODE>ColorSpace</CODE>. This model can be used to represent most color 
    models on most types of <CODE>GraphicsDevices</CODE>.
    <P></P></LI></UL>
  <UL>
    <LI><CODE>PackedColorModel</CODE> - a base class for models that represent 
    pixel values in which the color components are embedded directly in the bits 
    of an integer pixel. A <CODE>PackedColorModel</CODE> stores the packing 
    information that describes how color and alpha components are extracted from 
    the channel. The <CODE>DirectColorModel</CODE> is a 
    <CODE>PackedColorModel</CODE>.
    <P></P></LI></UL>
  <UL>
    <LI><CODE>FloatDoubleColorModel</CODE> - works with pixel values that 
    represent color and alpha information as separate samples, using float or 
    double elements.
    <P></P></LI></UL>The following sample code shows the construction of a 
  <CODE>ComponentColorModel</CODE> for an RGB color model.
  <P><CAPTION><FONT size=-1><B></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD rowspan="7" colspan="1"><PRE>     // Create an RGB color model
     int[] bits = { 8, 8, 8 };
     ColorModel colorModel = new
      ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                          bits, false, false,
                          Transparency.OPAQUE,
                          DataBuffer.TYPE_BYTE);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top">
  <HR>

  <P>The following sample code shows the construction of a 
  <CODE>ComponentColorModel</CODE> for a grayscale color model.
  <P><CAPTION><FONT size=-1><B></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD rowspan="6" colspan="1"><PRE>     // Create a grayscale color model.
     ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
     int bits[] = new int[] {8};
     ColorModel cm = new ComponentColorModel(cs, bits, false, false,
                                             Transparency.OPAQUE,
                                             DataBuffer.TYPE_BYTE);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top">
  <HR>

  <P>The following sample code shows the construction of a 
  <CODE>FloatDoubleColorModel</CODE> for a linear RGB color model.
  <P><CAPTION><FONT size=-1><B></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD rowspan="9" colspan="1"><PRE>     ColorSpace colorSpace =
         ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
     int[] bits = new int[3];
     bits[0] = bits[1] = bits[2] = 32;
     ColorModel cm = new FloatDoubleColorModel(colorSpace,
                                               false,
                                               false,
                                               Transparency.OPAQUE,
                                               DataBuffer.TYPE_FLOAT);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top"><TR valign="top"><TR valign="top">
  <HR>

  <P>
  <TABLE border=0>
    <TBODY>
    <TR>
      <TD><IMG src="Color Space.files/cistine.gif"></TD>
      <TD>
        <HR>
        <B>API:</B> <CODE>java.awt.image.ComponentColorModel </CODE>
        <HR>
      </TD></TR></TBODY></TABLE><PRE><UL>
<LI>ComponentColorModel(ColorSpace colorSpace, int[] bits, 
       boolean  hasAlpha, boolean isAlphaPremultiplied, 
       int  transparency, int transferType)
<P></P></LI></UL></PRE>
  <DL><A name=51303>
    <DT>
    <DD>constructs a <CODE>ComponentColorModel</CODE> from the specified 
    parameters.
    <P>
    <TABLE cellPadding=3 border=3>
      <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
      <TBODY>
      <TR vAlign=top>
        <TD><EM>Parameters</EM>:<EM></EM> 
          <P></P>
        <TD><CODE>colorSpace</CODE> 
          <P></P>
        <TD>The <CODE>ColorSpace</CODE> associated with this color model. See 
          <A 
          href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Color.doc.html#51305">Section 
          5.2.2, "Color Space</A>." 
          <P></P>
      <TR vAlign=top>
        <TD>
          <P></P>
        <TD><CODE>bits</CODE> 
          <P></P>
        <TD>The number of significant bits per component. 
          <P></P>
      <TR vAlign=top>
        <TD>
          <P></P>
        <TD><CODE>hasAlpha</CODE> 
          <P></P>
        <TD>If true, this color model supports alpha. 
          <P></P>
      <TR vAlign=top>
        <TD>
          <P></P>
        <TD><CODE>isAlphaPremultiplied</CODE> 
          <P></P>
        <TD>If true, alpha is premultiplied. 
          <P></P>
      <TR vAlign=top>
        <TD>
          <P></P>
        <TD><CODE>transparency</CODE> 
          <P></P>
        <TD>Specifies what alpha values can be represented by this color 
          model. See <A 
          href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Color.doc.html#51516">Section 
          5.3, "Transparency</A>." 
          <P></P>
      <TR vAlign=top>
        <TD>
          <P></P>
        <TD><CODE>transferType</CODE> 
          <P></P>
        <TD>Specifies the type of primitive array used to represent pixel 
          values. One of <CODE>DataBuffer.TYPE_BYTE</CODE>, 
          <CODE>DataBuffer.TYPE_INT</CODE>, <CODE>DataBuffer.TYPE_SHORT</CODE>, 
          <CODE>DataBuffer.TYPE_USHORT</CODE>, 
          <CODE>DataBuffer.TYPE_DOUBLE</CODE>, or 
          <CODE>DataBuffer.TYPE_FLOAT</CODE> 
          <P></P></TR></TBODY></TABLE></A>

⌨️ 快捷键说明

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