📄 image analysis.htm
字号:
<UL>
<LI>It takes the square root of the last two images forming the final image.
<P></P></LI></UL>The result of the <CODE>GradientMagnitude</CODE> operation
may be defined as:
<P>
<DL><A name=56426>
<DT>
<DD><IMG src="Image Analysis.files/Analysis.doc.ancA3.gif"> </A>
<P><A name=56061></P>
<DT>
<DD>where <CODE>SH(x,y,b)</CODE> and <CODE>SV(x,y,b)</CODE> are the
horizontal and vertical gradient images generated from band <EM>b</EM> of
the source image by correlating it with the supplied orthogonal (horizontal
and vertical) gradient masks. </A>
<P></P></DD></DL>The <CODE>GradientMagnitude</CODE> operation uses two
gradient masks; one for passing over the image in each direction. The
<CODE>GradientMagnitude</CODE> operation takes one rendered source image and
two parameters.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TH><A name=56095>Parameter </A>
<TH><A name=56097>Type </A>
<TH><A name=56099>Description </A>
<TR vAlign=top>
<TD><A name=56101>mask1</A><BR>
<TD><A name=56103>KernelJAI</A><BR>
<TD><A name=56105>A gradient mask.</A><BR>
<TR vAlign=top>
<TD><A name=56107>mask2</A><BR>
<TD><A name=56109>KernelJAI</A><BR>
<TD><A name=56111>A gradient mask orthogonal to the first
one.</A><BR></TR></TBODY></TABLE>
<P>The default masks for the <CODE>GradientMagnitude</CODE> operation are:
<P>
<UL>
<LI><CODE>KernelJAI.GRADIENT_MASK_SOBEL_HORIZONTAL</CODE>
<P></P></LI></UL>
<UL>
<LI><CODE>KernelJAI.GRADIENT_MASK_SOBEL_VERTICAL</CODE>
<P></P></LI></UL>These masks, shown in <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Analysis.doc.html#51239">Figure
9-2</A> perform the Sobel edge enhancement operation. The Sobel operation
extracts all of the edges in an image, regardless of the direction. The
resulting image appears as an omnidirectional outline of the objects in the
original image. Constant brightness regions are highlighted.
<P><A name=56375>
<HR>
<CENTER><IMG src="Image Analysis.files/Analysis.doc.anc1.gif"></CENTER>
<HR>
</A><A name=51239>
<CENTER><FONT size=-1><B><I>Figure 9-2 </I><IMG
src="Image Analysis.files/sm-blank.gif" border=0> Sobel Edge Enhancement
Masks</B></FONT></CENTER></A>
<P>The Roberts' cross edge enhancement operation uses the two masks shown in
<A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Analysis.doc.html#57055">Figure
9-3</A>. This operation extracts edges in an image by taking the combined
differences of directions at right angles to each other to determine the
gradient. The resulting image appears as a fairly-coarse directional outline
of the objects within the image. Constant brightness regions become black and
changing brightness regions become highlighted. The following is a listing of
how the two masks are constructed.
<P><CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<HR>
<TR valign="top"><TD rowspan="8" colspan="1"><PRE> float[] roberts_h_data = { 0.0F, 0.0F, -1.0F,
0.0F, 1.0F, 0.0F,
0.0F, 0.0F, 0.0F
};
float[] roberts_v_data = {-1.0F, 0.0F, 0.0F,
0.0F, 1.0F, 0.0F,
0.0F, 0.0F, 0.0F
};
</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"><TD><PRE> KernelJAI kern_h = new KernelJAI(3,3,roberts_h_data);
KernelJAI kern_v = new KernelJAI(3,3,roberts_v_data);
</PRE>
<HR>
<P><A name=57054>
<HR>
<CENTER><IMG src="Image Analysis.files/Analysis.doc.ancA5.gif"></CENTER>
<HR>
</A><A name=57055>
<CENTER><FONT size=-1><B><I>Figure 9-3 </I><IMG
src="Image Analysis.files/sm-blank.gif" border=0> Roberts' Cross Edge
Enhancement Masks</B></FONT></CENTER></A>
<P>The Prewitt gradient edge enhancement operation uses the two masks shown in
<A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Analysis.doc.html#57129">Figure
9-4</A>. This operation extracts the north, northeast, east, southeast, south,
southwest, west, or northwest edges in an image. The resulting image appears
as a directional outline of the objects within the image. Constant brightness
regions become black and changing brightness regions become highlighted. The
following is a listing of how the two masks are constructed.
<P><CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<HR>
<TR valign="top"><TD rowspan="8" colspan="1"><PRE> float[] prewitt_h_data = { 1.0F, 0.0F, -1.0F,
1.0F, 0.0F, -1.0F,
1.0F, 0.0F, -1.0F
};
float[] prewitt_v_data = {-1.0F, -1.0F, -1.0F,
0.0F, 0.0F, 0.0F,
1.0F, 1.0F, 1.0F
};
</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"><TD><PRE> KernelJAI kern_h = new KernelJAI(3,3,prewitt_h_data);
KernelJAI kern_v = new KernelJAI(3,3,prewitt_v_data);
</PRE>
<HR>
<P><A name=57128>
<HR>
<CENTER><IMG src="Image Analysis.files/Analysis.doc.anc8.gif"></CENTER>
<HR>
</A><A name=57129>
<CENTER><FONT size=-1><B><I>Figure 9-4 </I><IMG
src="Image Analysis.files/sm-blank.gif" border=0> Prewitt Edge Enhancement
Masks</B></FONT></CENTER></A>
<P>The Frei and Chen edge enhancement operation uses the two masks shown in <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Analysis.doc.html#57203">Figure
9-5</A>. This operation, when compared to the other edge enhancement,
operations, is more sensitive to a configuration of relative pixel values
independent of the brightness magnitude. The following is a listing of how the
two masks are constructed.
<P><CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<HR>
<TR valign="top"><TD rowspan="8" colspan="1"><PRE> float[] freichen_h_data = { 1.0F, 0.0F, -1.0F,
1.414F, 0.0F, -1.414F,
1.0F, 0.0F, -1.0F
};
float[] freichen_v_data = {-1.0F, -1.414F, -1.0F,
0.0F, 0.0F, 0.0F,
1.0F, 1.414F, 1.0F
};
</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"><TD><PRE> KernelJAI kern_h = new KernelJAI(3,3,freichen_h_data);
KernelJAI kern_v = new KernelJAI(3,3,freichen_v_data);
</PRE>
<HR>
<P><A name=57202>
<HR>
<CENTER><IMG src="Image Analysis.files/Analysis.doc.anc9.gif"></CENTER>
<HR>
</A><A name=57203>
<CENTER><FONT size=-1><B><I>Figure 9-5 </I><IMG
src="Image Analysis.files/sm-blank.gif" border=0> Frei and Chen Edge
Enhancement Masks</B></FONT></CENTER></A>
<P>To use a different mask, see <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Image-manipulation.doc.html#70882">Section
6.9, "Constructing a Kernel</A>."
<P><A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Analysis.doc.html#56654">Listing
9-4</A> shows a sample listing for a <CODE>GradientMagnitude</CODE> operation,
using the Frei and Chen edge detection kernel.
<P><CAPTION><FONT size=-1><B><A name=56654>
<CENTER><FONT size=-1><B><I>Listing 9-4 </I><IMG
src="Image Analysis.files/sm-blank.gif" border=0> Example GradientMagnitude
Operation </B></FONT></CENTER></A>
<P></B></FONT></CAPTION>
<HR>
<TR valign="top"><TD><PRE> // Load the image.
PlanarImage im0 = (PlanarImage)JAI.create("fileload",
filename);
</PRE><TR valign="top"><TD><PRE> // Create the two kernels.
float data_h[] = new float[] { 1.0F, 0.0F, -1.0F,
1.414F, 0.0F, -1.414F,
1.0F, 0.0F, -1.0F};
float data_v[] = new float[] {-1.0F, -1.414F, -1.0F,
0.0F, 0.0F, 0.0F,
1.0F, 1.414F, 1.0F};
</PRE><TR valign="top"><TD><PRE> KernelJAI kern_h = new KernelJAI(3,3,data_h);
KernelJAI kern_v = new KernelJAI(3,3,data_v);
</PRE><TR valign="top"><TD><PRE> // Create the Gradient operation.
PlanarImage im1 =
(PlanarImage)JAI.create("gradientmagnitude", im0,
kern_h, kern_v);
</PRE><TR valign="top"><TD><PRE> // Display the image.
imagePanel = new ScrollingImagePanel(im1, 512, 512);
add(imagePanel);
pack();
show();
</PRE>
<HR>
<P><A name=52769>
<H2>9.6 <IMG src="Image Analysis.files/space.gif">Statistical
Operations</H2></A>The <CODE>StatisticsOpImage</CODE> class is an abstract
class for image operators that compute statistics on a given region of an
image and with a given sampling rate. A subclass of
<CODE>StatisticsOpImage</CODE> simply passes pixels through unchanged from its
parent image. However, the desired statistics are available as a property or
set of properties on the image (see <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Properties.doc.html#47285">Chapter
11, "Image Properties</A>").
<P>All instances of <CODE>StatisticsOpImage</CODE> make use of a region of
interest, specified as an <CODE>ROI</CODE> object. Additionally, they may
perform spatial subsampling of the region of interest according to
<CODE>xPeriod</CODE> and <CODE>yPeriod</CODE> parameters that may vary from 1
(sample every pixel of the <CODE>ROI</CODE>) upwards. This allows the speed
and quality of statistics gathering to be traded off against one another.
<P>The <CODE>accumulateStatistics</CODE> method is used to accumulate
statistics on a specified region into the previously-created statistics
object.<CODE></CODE>
<P>
<TABLE border=0>
<TBODY>
<TR>
<TD><IMG src="Image Analysis.files/cistine.gif"></TD>
<TD>
<HR>
<B>API:</B> <CODE>javax.media.jai.StatisticsOpImage </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>StatisticsOpImage()
<P></P></LI></UL></PRE>
<DL><A name=53844>
<DT>
<DD>constructs a default <CODE>StatisticsOpImage</CODE>. </A>
<P></P></DD></DL><PRE><UL>
<LI>StatisticsOpImage(RenderedImage source, ROI roi, int xStart,
int yStart, int xPeriod, int yPeriod, int maxWidth, <BR>
int maxHeight)
<P></P></LI></UL></PRE>
<DL><A name=53877>
<DT>
<DD>constructs a <CODE>StatisticsOpImage</CODE>. The image layout is copied
from the source image.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=8><EM>Parameters</EM>:<EM></EM>
<P></P>
<TD><CODE>source</CODE>
<P></P>
<TD>A <CODE>RenderedImage</CODE>.
<P></P>
<TR vAlign=top>
<TD><CODE>roi</CODE>
<P></P>
<TD>The region of interest, as an <CODE>ROI</CODE>.
<P></P>
<TR vAlign=top>
<TD><CODE>xStart</CODE>
<P></P>
<TD>The initial <EM>x</EM> sample coordinate.
<P></P>
<TR vAlign=top>
<TD><CODE>ystart</CODE>
<P></P>
<TD>The initial <EM>y</EM> sample coordinate.
<P></P>
<TR vAlign=top>
<TD><CODE>xPeriod</CODE>
<P></P>
<TD>The <EM>x</EM> sampling rate.
<P></P>
<TR vAlign=top>
<TD><CODE>yPeriod</CODE>
<P></P>
<TD>The <EM>y</EM> sampling rate.
<P></P>
<TR vAlign=top>
<TD><CODE>maxWidth</CODE>
<P></P>
<TD>The largest allowed width for processing.
<P></P>
<TR vAlign=top>
<TD><CODE>maxHeight</CODE>
<P></P>
<TD>The largest allowed height for processing.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL>
<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="Image Analysis.files/contents.gif"></A> <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Geom-image-manip.doc.html"><IMG
alt=Previous src="Image Analysis.files/previous.gif"></A> <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Graphics.doc.html"><IMG
alt=Next src="Image Analysis.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 18:01:25 1999 --></BLOCKQUOTE>
<SCRIPT language=JavaScript
src="Image Analysis.files/s_code_remote.js"></SCRIPT>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -