📄 365-371.html
字号:
<HTML>
<HEAD>
<META name=vsisbn content="1558515682"><META name=vstitle content="Java Digital Signal Processing"><META name=vsauthor content="Douglas A. Lyon"><META name=vsimprint content="M&T Books"><META name=vspublisher content="IDG Books Worldwide, Inc."><META name=vspubdate content="11/01/97"><META name=vscategory content="Web and Software Development: Programming, Scripting, and Markup Languages: Java"><TITLE>Java Digital Signal Processing:Image Processing in Java</TITLE>
<!-- HEADER --><STYLE type="text/css"> <!-- A:hover { color : Red; } --></STYLE><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<!--ISBN=1558515682//-->
<!--TITLE=Java Digital Signal Processing//-->
<!--AUTHOR=Douglas A. Lyon//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=9//-->
<!--PAGES=365-371//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="361-365.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="371-374.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading8"></A><FONT COLOR="#000077">DiffCAD and the Example 2-D FFTs</FONT></H4>
<P>Some examples of Fourier transform pairs are shown in the following figures. On the left is <I>f(x,y)</I>. On the right is <I>F(u,v)</I>. The results are obtained using the DiffCAD program.</P>
<P>To improve the visibility of the PSD, we auto-scale and invert the PSD. Figure 9.3 shows one square painted with a bitmapped paint program called Debabelizer [Debabelizer].</P>
<P><A NAME="Fig3"></A><A HREF="javascript:displayWindow('images/09-03.jpg',270,141 )"><IMG SRC="images/09-03t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/09-03.jpg',270,141)"><FONT COLOR="#000077"><B>Figure 9.3</B></FONT></A> A square and its PSD.</P>
<P>Figure 9.4 shows a black ring (which acts as a notch filter) with its PSD.
</P>
<P><A NAME="Fig4"></A><A HREF="javascript:displayWindow('images/09-04.jpg',283,137 )"><IMG SRC="images/09-04t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/09-04.jpg',283,137)"><FONT COLOR="#000077"><B>Figure 9.4</B></FONT></A> A black ring and its PSD.</P>
<P>These images are used as input. To gain a little more control than exists in most paint programs, we have retrofitted the <I>PixelPlane</I> class with a <I>dot</I> method. It permits the generation of a filled circle (like that shown in Figure 9.5) with a specified radius.</P>
<P><A NAME="Fig5"></A><A HREF="javascript:displayWindow('images/09-05.jpg',219,136 )"><IMG SRC="images/09-05t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/09-05.jpg',219,136)"><FONT COLOR="#000077"><B>Figure 9.5</B></FONT></A> A black dot with its PSD.</P>
<P>The code for the <I>dot</I> method follows:</P>
<!-- CODE //-->
<PRE>
public void dot(int xc, int yc, int r) {
int x1 = 0;
int y1 = 0;
int x2 = getWidth();
int y2 = getHeight();
float r2 = r * r;
for (int x = x1; x < x2; x++)
for (int y = y1; y < y2; y++) {
if (((x-xc)*(x-xc) + (y-yc)*(y-yc)) < r2)
setPixel(x,y,0,0,0,255);
else
setPixel(x,y,255,255,255,255);
}
}
</PRE>
<!-- END CODE //-->
<P>To synthesize diffraction gratings (a research goal of the DiffCAD program), we add a <I>lines</I> method to the <I>ProcessPlane</I> whose prototype is given by the following:</P>
<!-- CODE SNIP //-->
<PRE>
public void lines(Rectangle r, int increment)
</PRE>
<!-- END CODE SNIP //-->
<P>Figure 9.6 shows an odd-shaped circle with its PSD.
</P>
<P><A NAME="Fig6"></A><A HREF="javascript:displayWindow('images/09-06.jpg',232,137 )"><IMG SRC="images/09-06t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/09-06.jpg',232,137)"><FONT COLOR="#000077"><B>Figure 9.6</B></FONT></A> An odd-shaped circle with its PSD.</P>
<P>Figures 9.7–9.10 show PSDs multiplied by bilevel images. After the multiplication is performed, an IFFT is taken. This process enables the construction of images that can be used as filters in the frequency domain.
</P>
<P><A NAME="Fig7"></A><A HREF="javascript:displayWindow('images/09-07.jpg',271,126 )"><IMG SRC="images/09-07t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/09-07.jpg',271,126)"><FONT COLOR="#000077"><B>Figure 9.7</B></FONT></A> A triangle with its PSD.</P>
<P><A NAME="Fig8"></A><A HREF="javascript:displayWindow('images/09-08.jpg',283,127 )"><IMG SRC="images/09-08t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/09-08.jpg',283,127)"><FONT COLOR="#000077"><B>Figure 9.8</B></FONT></A> mandrill with its PSD.</P>
<P><A NAME="Fig9"></A><A HREF="javascript:displayWindow('images/09-09.jpg',338,136 )"><IMG SRC="images/09-09t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/09-09.jpg',338,136)"><FONT COLOR="#000077"><B>Figure 9.9</B></FONT></A> A filter that removes some of the low frequencies from the mandrill and the IFFT.</P>
<P><A NAME="Fig10"></A><A HREF="javascript:displayWindow('images/09-10.jpg',378,125 )"><IMG SRC="images/09-10t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/09-10.jpg',378,125)"><FONT COLOR="#000077"><B>Figure 9.10</B></FONT></A> A filter that removes some of the high frequencies from the mandrill and the IFFT.</P>
<P>Another neat trick we can perform with the FFT is Fraunhofer diffraction, a special case of Fresnel diffraction that occurs either when the distance from the grating (the aperture) is large or when the rules in the grating are close together. Fraunhofer diffraction is used when you’re performing X-ray diffraction for studying underlying crystal-like structures (such as DNA). DiffCAD uses Fraunhofer diffraction to perform diffraction-based range finding [DeWitt and Lyon]. The following formula (whose derivation appears in [Walker]) shows the relationship between the DFT and Fraunhofer diffraction:
</P>
<P ALIGN="CENTER"><IMG SRC="images/09-27d.jpg"></P>
<P>(9.15)
</P>
<P>Where ( is the wavelength of light, <I>I</I>(<I>u</I>,<I>v</I>,<I>D</I>) is the intensity from Fraunhofer diffraction, and <I>D</I> is the distance between the target and the grating. ( is the 2-D Fourier transform of the aperture (grating):</P>
<P ALIGN="CENTER"><IMG SRC="images/09-28d.jpg"></P>
<P>(9.16)
</P>
<P>Figure 9.11, with its associated FFT, is an example of a far-field diffraction image computed by taking an FFT.</P>
<P><A NAME="Fig11"></A><A HREF="javascript:displayWindow('images/09-11.jpg',290,129 )"><IMG SRC="images/09-11t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/09-11.jpg',290,129)"><FONT COLOR="#000077"><B>Figure 9.11</B></FONT></A> A grating with associated PSD.</P>
<P>An increment parameter is input using the scale dialog box and indicates the number of pixels to be skipped between lines. An example of the use of the <I>ProcessPlane</I> is given in the <I>ImageFrame</I> class:</P>
<!-- CODE SNIP //-->
<PRE>
public void lines() {
pp.lines(bounds(),scaleKonst.getValue());
updateDisplay(pp);
}
</PRE>
<!-- END CODE SNIP //-->
<P>A variable-interrule-width grating (called a <I>chirp</I> grating) can give a radically different diffraction pattern from that of a fixed-width grating. An example is shown in Figure 9.12.</P>
<P><A NAME="Fig12"></A><A HREF="javascript:displayWindow('images/09-12.jpg',267,129 )"><IMG SRC="images/09-12t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/09-12.jpg',267,129)"><FONT COLOR="#000077"><B>Figure 9.12</B></FONT></A> A chirp grating with PSD.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>For the diffraction images shown, [lambda] <I>D</I> = 1. If [lambda] = 638 nm (about the wavelength of a He-Ne laser) then <I>D</I> = 1/ [lambda] =1.5 million meters.<HR></FONT>
</BLOCKQUOTE>
<P>Based on the assumption that the light is far, the FFT can assist us directly in the computation of Equation 9.16. At modest distance and with a small aperture relative to <I>D</I>, we can use the Fresnel diffraction formula:</P>
<P ALIGN="CENTER"><IMG SRC="images/09-29d.jpg"></P>
<P>(9.17)
</P>
<P>Developing code to solve Equation 9.17 is beyond the scope of this book. A numeric solution of Equation 9.17 can be found in [Baker].</P>
<H3><A NAME="Heading9"></A><FONT COLOR="#000077">Raster to Vector Conversion</FONT></H3>
<P>Now let’s see how to turn an edge-detected image into a list of line segments. We take an ad hoc approach to the conversion that runs in <I>O</I>(<I>N<SUP>2</SUP></I>) time. For small numbers of <I>N</I> the quadratic growth does not appear to be a problem. We do not address refinements to the algorithm.</P>
<P>Converting a list of point coordinates into vectors (line segments) has applications in the graphic arts, CAD, and computer vision. In the graphic arts we use the vectors to form an editable outline of an image. The outline can be reproduced without the jaggies inherent in bitmapped images. In CAD we use the vectors to help construct a geometric model. In computer vision, we use the vectors to obtain geometric features that can be used in recognition. Another application for raster to vector conversion is in the output of line data using a vector-based device. For example, a pen plotter that uses a mechanical arm to deflect a pen must have the raster data converted to vector for efficient operation. Vector display systems (such as laser-based mirror deflection systems) form another class of devices that use the raster to vector conversion. In addition to converting from raster to vector, we must also order the vectors end-to-end to speed plotting on a mechanical pen plotter by minimizing the pen-up time. A pen plotter typically lifts a pen from the drawing surface before attempting to draw. A vector display device (such as an oscilloscope or laser) typically uses a blanking signal to turn off the beam. If the vector list is not retraced often enough, a human viewing the image will experience the sensation of flicker. Ordering the vectors maximizes the number of vectors to be displayed without flicker.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="361-365.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="371-374.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<hr width="90%" size="1" noshade><div align="center"><font face="Verdana,sans-serif" size="1">Copyright © <a href="/reference/idgbooks00001.html">IDG Books Worldwide, Inc.</a></font></div>
<!-- all of the reference materials (books) have the footer and subfoot reveresed --><!-- reference_subfoot = footer --><!-- reference_footer = subfoot --></BODY></HTML><!-- END FOOTER -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -