📄 image manipulation.htm
字号:
<LI>boolean contains(int x, int y, int w, int h)
<P></P></LI></UL></PRE>
<DL><A name=53784>
<DT>
<DD>returns true if the rectangular region is entirely contained within the
<CODE>ROI</CODE>.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=4><EM>Parameters</EM>:
<P></P>
<TD><CODE>x</CODE>
<P></P>
<TD>The <EM>x</EM> coordinate of the pixel to be queried.
<P></P>
<TR vAlign=top>
<TD><CODE>y</CODE>
<P></P>
<TD>The <EM>y</EM> coordinate of the pixel to be queried.
<P></P>
<TR vAlign=top>
<TD><CODE>w</CODE>
<P></P>
<TD>The width of the region.
<P></P>
<TR vAlign=top>
<TD><CODE>h</CODE>
<P></P>
<TD>The height of the region.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>boolean contains(double x, double y, double w, double h)
<P></P></LI></UL></PRE>
<DL><A name=53788>
<DT>
<DD>returns true if the rectangular region is entirely contained within the
<CODE>ROI</CODE>.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=4><EM>Parameters</EM>:
<P></P>
<TD><CODE>x</CODE>
<P></P>
<TD>The <EM>x</EM> coordinate of the pixel to be queried.
<P></P>
<TR vAlign=top>
<TD><CODE>y</CODE>
<P></P>
<TD>The <EM>y</EM> coordinate of the pixel to be queried.
<P></P>
<TR vAlign=top>
<TD><CODE>w</CODE>
<P></P>
<TD>The width of the region.
<P></P>
<TR vAlign=top>
<TD><CODE>h</CODE>
<P></P>
<TD>The height of the region.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>boolean intersects(Rectangle rect)
<P></P></LI></UL></PRE>
<DL><A name=53792>
<DT>
<DD>returns true if the rectangular region intersects the <CODE>ROI</CODE>.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameters</EM>:
<P></P>
<TD><CODE>rect</CODE>
<P></P>
<TD>The region to be tested for inclusion.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>boolean intersects(Rectangle2D r)
<P></P></LI></UL></PRE>
<DL><A name=53796>
<DT>
<DD>returns true if the rectangular region intersects the <CODE>ROI</CODE>.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameters</EM>:
<P></P>
<TD><CODE>rect</CODE>
<P></P>
<TD>The region to be tested for inclusion.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>boolean intersects(int x, int y, int w, int h)
<P></P></LI></UL></PRE>
<DL><A name=53800>
<DT>
<DD>returns true if the rectangular region intersects the <CODE>ROI</CODE>.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=4><EM>Parameters</EM>:
<P></P>
<TD><CODE>x</CODE>
<P></P>
<TD>The <EM>x</EM> coordinate of the upper left corner of the region.
<P></P>
<TR vAlign=top>
<TD><CODE>y</CODE>
<P></P>
<TD>The <EM>y</EM> coordinate of the upper left corner of the region.
<P></P>
<TR vAlign=top>
<TD><CODE>w</CODE>
<P></P>
<TD>The width of the region.
<P></P>
<TR vAlign=top>
<TD><CODE>h</CODE>
<P></P>
<TD>The height of the region.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>boolean intersects(double x, double y, double w, double h)
<P></P></LI></UL></PRE>
<DL><A name=53804>
<DT>
<DD>returns true if the rectangular region intersects the <CODE>ROI</CODE>.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=4><EM>Parameters</EM>:
<P></P>
<TD><CODE>x</CODE>
<P></P>
<TD>The <EM>x</EM> coordinate of the upper left corner of the region.
<P></P>
<TR vAlign=top>
<TD><CODE>y</CODE>
<P></P>
<TD>The <EM>y</EM> coordinate of the upper left corner of the region.
<P></P>
<TR vAlign=top>
<TD><CODE>w</CODE>
<P></P>
<TD>The width of the region.
<P></P>
<TR vAlign=top>
<TD><CODE>h</CODE>
<P></P>
<TD>The height of the region.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><A name=55680>
<H4>6.2.2.3 <IMG src="Image Manipulation.files/space.gif">Creating a New
ROIShape from an Existing ROIShape</H4></A>Several methods allow the creation
of a new <CODE>ROIShape</CODE> from the old <CODE>ROIShape</CODE>.
<P>
<TABLE border=0>
<TBODY>
<TR>
<TD><IMG src="Image Manipulation.files/cistine.gif"></TD>
<TD>
<HR>
<B>API:</B> <CODE>javax.media.jai.ROIShape </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>ROI add(ROI im)
<P></P></LI></UL></PRE>
<DL><A name=53808>
<DT>
<DD>adds another mask to this one. This operation may force this mask to be
rendered.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameters</EM>:
<P></P>
<TD><CODE>im</CODE>
<P></P>
<TD>An <CODE>ROI</CODE>.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>ROI subtract(ROI im)
<P></P></LI></UL></PRE>
<DL><A name=53812>
<DT>
<DD>subtracts another mask from this one. This operation may force this mask
to be rendered.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameters</EM>:
<P></P>
<TD><CODE>im</CODE>
<P></P>
<TD>An <CODE>ROI</CODE>.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>ROI intersect(ROI im)
<P></P></LI></UL></PRE>
<DL><A name=53816>
<DT>
<DD>sets the mask to its intersection with another mask. This operation may
force this mask to be rendered.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameters</EM>:
<P></P>
<TD><CODE>im</CODE>
<P></P>
<TD>An <CODE>ROI</CODE>.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>ROI exclusiveOr(ROI im)
<P></P></LI></UL></PRE>
<DL><A name=53820>
<DT>
<DD>sets the mask to its exclusive-OR with another mask. This operation may
force this mask to be rendered.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameters</EM>:
<P></P>
<TD><CODE>im</CODE>
<P></P>
<TD>An <CODE>ROI</CODE>.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>ROI transform(AffineTransform at)
<P></P></LI></UL></PRE>
<DL><A name=53824>
<DT>
<DD>performs an affine transformation and returns the result as a new ROI.
The transformation is performed by an "Affine" RIF.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameters</EM>:
<P></P>
<TD><CODE>at</CODE>
<P></P>
<TD>The affine transform.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>Shape getAsShape()
<P></P></LI></UL></PRE>
<DL><A name=55786>
<DT>
<DD>returns the internal <CODE>Shape</CODE> representation or null if not
possible. Since we have a shape available, we simply return it. </A>
<P></P></DD></DL><PRE><UL>
<LI>PlanarImage getAsImage()
<P></P></LI></UL></PRE>
<DL><A name=55796>
<DT>
<DD>returns the shape as a <CODE>PlanarImage</CODE>. This requires
performing an antialiased rendering of the internal <CODE>Shape</CODE>. We
use an eight-bit, single channel image with a
<CODE>ComponentColorModel</CODE> and a <CODE>ColorSpace.TYPE_GRAY</CODE>
color space. </A>
<P></P></DD></DL><A name=51159>
<H2>6.3 <IMG src="Image Manipulation.files/space.gif">Relational
Operators</H2></A>Given two source images and a destination image, the JAI
relational operators allow you to:
<P>
<UL>
<LI>Find the larger of the pixels in the two source images and store the
results in the destination (<CODE>Max</CODE>).
<P></P></LI></UL>
<UL>
<LI>Find the smaller of the pixels in the two source images and store the
results in the destination (<CODE>Min</CODE>).
<P></P></LI></UL>The relational operators require that both source images and
the destination image have the same data type and number of bands. The sizes
of the two images (height and width), however, need not be the same.
<P>When determining the maximum and minimum pixels in the two images, JAI
performs a band-by-band comparison.
<P>
<HR noShade>
<B>Note:</B> Don't confuse the relational Min and Max operators with the
Extrema operation (see <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Analysis.doc.html#54907">Section
9.3, "Finding the Extrema of an Image</A>"), which finds the image-wise
minimum and maximum pixel values for each band of an image.
<HR noShade>
<A name=58435>
<H3>6.3.1 <IMG src="Image Manipulation.files/space.gif">Finding the Maximum
Values of Two Images</H3></A>The <CODE>max</CODE> operation takes two rendered
images, and for every pair of pixels, one from each source image of the
corresponding position and band, finds the maximum pixel value.
<P>The two source images may have different numbers of bands and data types.
By default, the destination image bound is the intersection of the two source
image bounds. If the two source images don't intersect, the destination will
have a width and a height of 0. The number of bands of the destination image
is the same as the least number of bands of the source images, and the data
type is the biggest data type of the source images.
<P>The pixel values of the destination image are defined by the following
pseudocode:
<P><PRE> if (srcs[0][x][y][b] > srcs[1][x][y][b]) {
dst[x][y][b] = srcs[0][x][y][b];
} else {
dst[x][y][b] = srcs[1][x][y][b];
}
</PRE>The <CODE>max</CODE> operation takes two source images and no
parameters. <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Image-manipulation.doc.html#70421">Listing
6-1</A> shows a partial code sample of computing the pixelwise maximum value
of two images in the rendered mode.
<P><CAPTION><FONT size=-1><B><A name=70421>
<CENTER><FONT size=-1><B><I>Listing 6-1 </I><IMG
src="Image Manipulation.files/sm-blank.gif" border=0> Finding the Maximum
Value of Two Images</B></FONT></CENTER></A>
<P></B></FONT></CAPTION>
<HR>
<TR valign="top"><TD rowspan="6" colspan="1"><PRE> // Create two constant images
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -