📄 color space.htm
字号:
<P></P></LI></UL></PRE>
<DL><A name=51488>
<DT>
<DD>transforms a color value assumed to be in the <CODE>CS_CIEXYZ</CODE>
conversion color space into this <CODE>ColorSpace</CODE>. </A>
<P></P></DD></DL><PRE><UL>
<LI>static ColorSpace getInstance(int colorspace)
<P></P></LI></UL></PRE>
<DL><A name=51497>
<DT>
<DD>returns a ColorSpace representing one of the specific predefined color
spaces.
<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>colorSpace</CODE>
<P></P>
<TD>A specific color space identified by one of the predefined class
constants (e.g., <CODE>CS_sRGB</CODE>, <CODE>CS_LINEAR_RGB</CODE>,
<CODE>CS_CIEXYZ</CODE>, <CODE>CS_GRAY</CODE>, or
<CODE>CS_PYCC</CODE>).
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>int getType()
<P></P></LI></UL></PRE>
<DL><A name=51499>
<DT>
<DD>returns the color space type of this <CODE>ColorSpace</CODE> (for
example <CODE>TYPE_RGB</CODE>, <CODE>TYPE_XYZ</CODE>, etc.). </A>
<P></P></DD></DL><A name=51500>
<H3>5.2.3 <IMG src="Color Space.files/space.gif">ICC Profile and ICC Color
Space</H3></A>The <CODE>ColorSpace</CODE> class is an abstract class. It is
expected that particular implementations of subclasses of
<CODE>ColorSpace</CODE> will support high performance conversion based on
underlying platform color management systems. The <CODE>ICC_ColorSpace</CODE>
class is one such implementation provided in the base AWT. Developers can
define their own subclasses to represent arbitrary color spaces, as long as
the appropriate "to" and "from" conversion methods are implemented. However,
most developers can simply use the default <CODE>sRGB</CODE> color space or
color spaces that are represented by commonly-available ICC profiles, such as
profiles for monitors and printers or profiles embedded in image
data.<CODE></CODE>
<P>The <CODE>ICC_ColorSpace</CODE> class is based on ICC profile data as
represented by the <CODE>ICC_Profile</CODE> class. The
<CODE>ICC_Profile</CODE> class is a representation of color profile data for
device-independent and device-dependent color spaces based on the <EM>ICC
Profile Format Specification</EM>, Version 3.4, August 15, 1997, from the
International Color Consortium. ICC profiles describe an <EM>input space</EM>
and a <EM>connection space</EM>, and define how to map between them.
<P>The <CODE>ICC_Profile</CODE> class has two subclasses that correspond to
the specific color types:
<P>
<UL>
<LI><CODE>ICC_ProfileRGB</CODE>, which represents <CODE>TYPE_RGB</CODE>
color spaces
<P></P></LI></UL>
<UL>
<LI><CODE>ICC_ProfileGray</CODE>, which represents <CODE>TYPE_GRAY</CODE>
color spaces
<P></P></LI></UL><A name=51516>
<H2>5.3 <IMG src="Color Space.files/space.gif">Transparency</H2></A>Just as
images can have color, they can also have transparency. Transparency defines
the specular transmission of light through transparent materials, such as
glass, or the lack of transparency for completely opaque objects. The amount
of transparency is specified by an alpha (<IMG
src="Color Space.files/alpha.gif">) value. An alpha value of 0.0 specifies
complete translucency; an alpha value of 1.0 specifies complete opacity.
<P>Images can carry transparency information, known as the alpha channel, for
each pixel in the image. The alpha value is particularly important when colors
overlap. The alpha value specifies how much of the previously-rendered color
should show through.
<P>The Java <CODE>Transparency</CODE> interface defines the common
transparency modes for implementing classes. <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Color.doc.html#51528">Table
5-2</A> lists the variables used to specify transparency.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B><A name=51528><I>Table 5-2 </I><IMG
src="Color Space.files/sm-blank.gif" border=0> Transparency
</A></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TH><A name=51532>Name </A>
<TH><A name=51534>Description </A>
<TR vAlign=top>
<TD><A name=51537>BITMASK</A><BR>
<TD><A name=51539>Represents image data that is guaranteed to be either
completely opaque, with an alpha value of 1.0, or completely
transparent, with an alpha value of 0.0.</A><BR>
<TR vAlign=top>
<TD><A name=51542>OPAQUE</A><BR>
<TD><A name=51544>Represents image data that is guaranteed to be
completely opaque, meaning that all pixels have an alpha value of
1.0.</A><BR>
<TR vAlign=top>
<TD><A name=51547>TRANSLUCENT</A><BR>
<TD><A name=51549>Represents image data that contains or might contain
arbitrary alpha values between and including 0.0 and
1.0.</A><BR></TR></TBODY></TABLE>
<P>Transparency is specified as part of the color model (see <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Color.doc.html#51226">Section
5.2.1, "Color Models</A>").
<P><A name=51551>
<H2>5.4 <IMG src="Color Space.files/space.gif">Color Conversion</H2></A>The
<CODE>ColorConvert</CODE> operation performs a pixel-by-pixel color conversion
of the data in a rendered or renderable source image. The data are treated as
having no alpha channel, i.e., all bands are color bands. The color space of
the source image is specified by the <CODE>ColorSpace</CODE> object of the
source image <CODE>ColorModel</CODE> which must not be null.
<P>JAI does not attempt to verify that the <CODE>ColorModel</CODE> of the
destination image is consistent with the <CODE>ColorSpace</CODE> parameter. To
ensure that this is the case, a compatible <CODE>ColorModel</CODE> must be
provided via an <CODE>ImageLayout</CODE> in the <CODE>RenderingHints</CODE>
(see <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Programming-environ.doc.html#55991">Section
3.7.3, "Rendering Hints</A>").
<P>Integral data are assumed to occupy the full range of the respective data
type; floating point data are assumed to be normalized to the range [0.0,1.0].
By default, the destination image bounds, data type, and number of bands are
the same as those of the source image.
<P>The <CODE>ColorConvert</CODE> operation takes one parameter:
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TH><A name=51557>Parameters </A>
<TH><A name=51559>Type </A>
<TH><A name=51561>Description </A>
<TR vAlign=top>
<TD><A name=51563>colorSpace</A><BR>
<TD><A name=51565>ColorSpace</A><BR>
<TD><A name=51567>The destination color space.</A><BR></TR></TBODY></TABLE>
<P>For information on color space, 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><A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Color.doc.html#51792">Listing
5-1</A> shows a code sample for a <CODE>ColorConvert</CODE> operation.
<P><CAPTION><FONT size=-1><B><A name=51792>
<CENTER><FONT size=-1><B><I>Listing 5-1 </I><IMG
src="Color Space.files/sm-blank.gif" border=0> Example ColorConvert
Operation</B></FONT></CENTER></A>
<P></B></FONT></CAPTION>
<HR>
<TR valign="top"><TD><PRE> // Read the image from the specified file name.
RenderedOp src = JAI.create("fileload", fileName);
</PRE><TR valign="top"><TD><PRE> // Create the ParameterBlock.
ParameterBlock pb = new ParameterBlock();
pb.addSource(src).add(colorSpace);
</PRE><TR valign="top"><TD><PRE> // Perform the color conversion.
RenderedOp dst = JAI.create("ColorConvert", pb);
</PRE>
<HR>
<P><A name=51591>
<H2>5.5 <IMG src="Color Space.files/space.gif">Non-standard Linear Color
Conversion (BandCombine)</H2></A>In JAI, the <CODE>BandCombine</CODE>
operation performs a linear color conversion between color spaces other than
those listed in <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Color.doc.html#51319">Table
5-1</A>. The <CODE>BandCombine</CODE> operation computes a set of arbitrary
linear combinations of the bands of a rendered or renderable source image,
using a specified matrix. The matrix must have dimension (# of source bands
plus one) by (# of desired destination bands).
<P>The <CODE>BandCombine</CODE> operation takes one parameter:
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TH><A name=51599>Parameter </A>
<TH><A name=51601>Type </A>
<TH><A name=51603>Description </A>
<TR vAlign=top>
<TD><A name=51605>matrix</A><BR>
<TD><A name=51607>double</A><BR>
<TD><A name=51609>The matrix specifying the band
combination.</A><BR></TR></TBODY></TABLE>
<P>As an example, assume the three-band source image and the matrix shown in
<A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Color.doc.html#51639">Figure
5-1</A>. The equation to calculate the value of the destination pixel in this
example would be:
<P>
<DL><A name=51615>
<DT>
<DD><EM>dst</EM> = (255 * 0.25) + (157 * 0.5) + (28 * 0.75) </A>
<P><A name=51637>
<HR>
<CENTER><IMG src="Color Space.files/Color.doc.anc.gif"></CENTER>
<HR>
</A></DD></DL><A name=51639>
<CENTER><FONT size=-1><B><I>Figure 5-1 </I><IMG
src="Color Space.files/sm-blank.gif" border=0> Band Combine
Example</B></FONT></CENTER></A>
<P>In this example, the number of columns in the matrix is equal to the number
of bands in the source image. The number of rows in the matrix must equal the
number of bands in the destination image. For a destination image with three
bands, the values in the second row of the matrix would be used to calculate
the values in the second band of the destination image and the values in the
third row would be used to calculate the values in the third band.
<P>If the result of the computation underflows or overflows the minimum or
maximum value supported by the destination image, it will be clamped to the
minimum or maximum value, respectively.
<P><A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Color.doc.html#51816">Listing
5-2</A> shows a code sample for a <CODE>BandCombine</CODE> operation.
<P><CAPTION><FONT size=-1><B><A name=51816>
<CENTER><FONT size=-1><B><I>Listing 5-2 </I><IMG
src="Color Space.files/sm-blank.gif" border=0> Example BandCombine
Operation</B></FONT></CENTER></A>
<P></B></FONT></CAPTION>
<HR>
<TR valign="top"><TD><PRE> // Create the matrix.
// Invert center band.
double[][] matrix = {
{ 1.0D, 0.0D, 0.0D, 0.0D },
{ 0.0D, -1.0D, 0.0D, 255.0D },
{ 0.0D, 0.0D, 1.0D, 0.0D },
};
</PRE><TR valign="top"><TD><PRE> // Identity.
double[][] matrix = {
{ 1.0D, 0.0D, 0.0D, 0.0D },
{ 0.0D, 1.0D, 0.0D, 0.0D },
{ 0.0D, 0.0D, 1.0D, 0.0D },
};
</PRE><TR valign="top"><TD><PRE> // Luminance stored into red band (3 band).
double[][] matrix = {
{ .114D, 0.587D, 0.299D, 0.0D },
{ .000D, 0.000D, 0.000D, 0.0D },
{ .000D, 0.000D, 0.000D, 0.0D }
};
</PRE><TR valign="top"><TD><PRE> // Luminance (single band output).
double[][] matrix = {
{ .114D, 0.587D, 0.299D, 0.0D }
};
</PRE><TR valign="top"><TD><PRE> // Create the ParameterBlock.
ParameterBlock pb = new ParameterBlock();
pb.addSource(src_image);
pb.add(matrix);
</PRE><TR valign="top"><TD><PRE> // Perform the band combine operation.
dst = (PlanarImage)JAI.create("bandcombine", pb, null);
</PRE>
<HR>
<P>
<P>
<HR>
<BR>
<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>
<H5><A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/copyright.html">Copyright</A>
© 1999, Sun Microsystems, Inc. All rights reserved.</H5><!-- Last updated: Tue Nov 02 17:30:41 1999 --></BLOCKQUOTE>
<SCRIPT language=JavaScript src="Color Space.files/s_code_remote.js"></SCRIPT>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -