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

📄 geometric image manipulation.htm

📁 是一部关于java高级图像处理的的一本入门书
💻 HTM
📖 第 1 页 / 共 5 页
字号:
  images geometrically. The translation is often carried out to align the images 
  before performing a combination operation, such as image addition, 
  subtraction, division, or compositing. 
  <P><A name=73212>
  <HR>

  <CENTER><IMG 
  src="Geometric Image Manipulation.files/Geom-image-manip.doc.anc36.gif"></CENTER>
  <HR>
  </A><A name=73213>
  <CENTER><FONT size=-1><B><I>Figure 8-4 </I><IMG 
  src="Geometric Image Manipulation.files/sm-blank.gif" border=0> Translate 
  Operation</B></FONT></CENTER></A>
  <P>The <CODE>translate</CODE> operation takes one rendered or renderable 
  source image and three parameters:
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=60889>Parameters </A>
      <TH><A name=60891>Type </A>
      <TH><A name=60893>Description </A>
    <TR vAlign=top>
      <TD><A name=60895>xTrans</A><BR>
      <TD><A name=60897>Float</A><BR>
      <TD><A name=60899>The displacement in the <EM>x</EM> direction. The 
        default value is 0.0F.</A><BR>
    <TR vAlign=top>
      <TD><A name=60901>yTrans</A><BR>
      <TD><A name=60903>Float</A><BR>
      <TD><A name=60905>The displacement in the <EM>y</EM> direction. The 
        default value is 0.0F.</A><BR>
    <TR vAlign=top>
      <TD><A name=60907>interpolation</A><BR>
      <TD><A name=60909>Interpolation</A><BR>
      <TD><A name=61259>The interpolation method for resampling. One of 
        INTERP_NEAREST, INTERP_BILINEAR, INTERP_BICUBIC, or INTERP_BICUBIC2. The 
        default value is null.</A><BR></TR></TBODY></TABLE>
  <P>The <CODE>xTrans</CODE> parameter corresponds to <EM>t</EM><SUB>x</SUB> and 
  the <CODE>yTrans</CODE> parameter corresponds to <EM>t</EM><SUB>y</SUB> in <A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Geom-image-manip.doc.html#60873">equation 
  8.1</A>. If <CODE>xTrans</CODE> is positive, the translation is to the right; 
  if negative, to the left. If <CODE>yTrans</CODE> is positive, the translation 
  is down; if negative, upward. If both <CODE>xTrans</CODE> and 
  <CODE>yTrans</CODE> are integral, the operation simply <EM>wraps</EM> its 
  source image to change the image's position in the coordinate plane. 
  <P>When interpolations that require padding the source such as bilinear or 
  bicubic interpolation are specified, the boundary of the source image needs to 
  be extended such that it has the extra pixels needed to compute all the 
  destination pixels. This extension is performed via the 
  <CODE>BorderExtender</CODE> class. The type of border extension can be 
  specified as a <CODE>RenderingHint</CODE> to the <CODE>JAI.create</CODE> 
  method. If no border extension type is provided, a default extension of 
  <CODE>BorderExtender.BORDER_COPY</CODE> will be used to perform the extension. 
  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><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Geom-image-manip.doc.html#69434">Listing 
  8-2</A> shows a code sample for a translate operation using nearest-neighbor 
  interpolation.
  <P><CAPTION><FONT size=-1><B><A name=69434>
  <CENTER><FONT size=-1><B><I>Listing 8-2 </I><IMG 
  src="Geometric Image Manipulation.files/sm-blank.gif" border=0> Example 
  Translate Operation</B></FONT></CENTER></A>
  <P></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD><PRE>     // Create a ParameterBlock and specify the source and
     // parameters.
     ParameterBlock pb = new ParameterBlock();
          pb.addSource(im);                   // The source image
          pb.add((float)Math.max(-mx, 0));    // The x translation
          pb.add((float)Math.max(-my, 0));    // The y translation
          pb.add(new InterpolationNearest()); // The interpolation
</PRE><TR valign="top"><TD><PRE>     // Create the translate operation
     im = JAI.create("translate", pb, null);
</PRE>
  <HR>

  <P><A name=60938>
  <H3>8.3.2 <IMG src="Geometric Image Manipulation.files/space.gif">Scaling 
  Transformation</H3></A>Scaling, also known as <EM>minification</EM> and 
  <EM>magnification</EM>, enlarges or shrinks an image. An <EM>x</EM>-value 
  defines the amount of scaling in the <EM>x</EM> direction, and a 
  <EM>y</EM>-value defines the amount of scaling in the <EM>y</EM> direction. 
  The <CODE>Scale</CODE> operation both translates and resizes. 
  <P>Scaling is often used to geometrically register multiple images prior to 
  performing a combination operation, such as image addition, subtraction, 
  division, or compositing. Scaling can also be used to correct geometric 
  distortions introduced in the image acquisition process, although the 
  <CODE>Affine</CODE> operation (<A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Geom-image-manip.doc.html#51275">"Affine 
  Transformation" on page 272</A>) would be more suitable for this. 
  <P>For each pixel (<EM>x</EM>, <EM>y</EM>) of the destination, the source 
  value at the fractional subpixel position is constructed by means of an 
  <CODE>Interpolation</CODE> object and written to the destination. 
  <P>
  <DL><A name=60948>
    <DT>
    <DD><IMG 
    src="Geometric Image Manipulation.files/Geom-image-manip.doc.anc6.gif"> </A>
    <P></P></DD></DL>The <CODE>scale</CODE> operation takes one rendered or 
  renderable source image and five parameters:
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=60951>Parameters </A>
      <TH><A name=60953>Type </A>
      <TH><A name=60955>Description </A>
    <TR vAlign=top>
      <TD><A name=60957>xScale</A><BR>
      <TD><A name=60959>Float</A><BR>
      <TD><A name=60961>The <EM>x</EM> scale factor.</A><BR>
    <TR vAlign=top>
      <TD><A name=60963>yScale</A><BR>
      <TD><A name=60965>Float</A><BR>
      <TD><A name=60967>The <EM>y</EM> scale factor.</A><BR>
    <TR vAlign=top>
      <TD><A name=60969>xTrans</A><BR>
      <TD><A name=60971>Float</A><BR>
      <TD><A name=60973>The <EM>x</EM> translation.</A><BR>
    <TR vAlign=top>
      <TD><A name=60975>xTrans</A><BR>
      <TD><A name=60977>Float</A><BR>
      <TD><A name=60979>The <EM>y</EM> translation.</A><BR>
    <TR vAlign=top>
      <TD><A name=60981>interpolation</A><BR>
      <TD><A name=60983>Interpolation</A><BR>
      <TD><A name=60985>The interpolation method for resampling. One of 
        INTERP_NEAREST, INTERP_BILINEAR, INTERP_BICUBIC, or 
        INTERP_BICUBIC2.</A><BR></TR></TBODY></TABLE>
  <P>When applying scale factors (<CODE>xScale</CODE> and <CODE>yScale</CODE>) 
  to a source image with width of <CODE>src_width</CODE> and height of 
  <CODE>src_height</CODE>, the resulting image is defined to have the following 
  dimensions: 
  <P><PRE>     dst_width = src_width * xScale
     dst_height = src_height * yScale
</PRE>Scale factors greater than 1.0 magnify the image; less than 1.0 minify 
  the image. The <CODE>xTrans</CODE> parameter corresponds to 
  <EM>t</EM><SUB>x</SUB> and the <CODE>yTrans</CODE> parameter corresponds to 
  <EM>t</EM><SUB>y</SUB> in <A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Geom-image-manip.doc.html#60873">equation 
  8.1</A>. If <CODE>xTrans</CODE> is positive, the translation is to the right; 
  if negative, to the left. If <CODE>yTrans</CODE> is positive, the translation 
  is down; if negative, upward. 
  <P><A name=73168>
  <HR>

  <CENTER><IMG 
  src="Geometric Image Manipulation.files/Geom-image-manip.doc.anc25.gif"></CENTER>
  <HR>
  </A><A name=73169>
  <CENTER><FONT size=-1><B><I>Figure 8-5 </I><IMG 
  src="Geometric Image Manipulation.files/sm-blank.gif" border=0> Scale 
  Operation</B></FONT></CENTER></A>
  <P>When interpolations that require padding the source such as Bilinear or 
  Bicubic interpolation are specified, the boundary of the source image needs to 
  be extended such that it has the extra pixels needed to compute all the 
  destination pixels. This extension is performed via the 
  <CODE>BorderExtender</CODE> class. The type of border extension can be 
  specified as a <CODE>RenderingHint</CODE> to the <CODE>JAI.create</CODE> 
  method. 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>If no Border Extension is specified, the source will not be extended. The 
  scaled image size is still calculated according to the equation specified 
  above. However since there isn't enough source to compute all the destination 
  pixels, only that subset of the destination image's pixels that can be 
  computed will be written in the destination. The rest of the destination will 
  not be written. 
  <P><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Geom-image-manip.doc.html#69465">Listing 
  8-3</A> shows a code sample for a <CODE>Scale</CODE> operation using a scale 
  factor of 1.2 and nearest-neighbor interpolation.
  <P><CAPTION><FONT size=-1><B><A name=69465>
  <CENTER><FONT size=-1><B><I>Listing 8-3 </I><IMG 
  src="Geometric Image Manipulation.files/sm-blank.gif" border=0> Example Scale 
  Operation</B></FONT></CENTER></A>
  <P></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD><PRE>     // Create a ParameterBlock and specify the source and
     // parameters
     ParameterBlock pb = new ParameterBlock();
          pb.addSource(im);                   // The source image
          pb.add(1.2);                        // The xScale
          pb.add(1.2);                        // The yScale
          pb.add(0.0F);                       // The x translation
          pb.add(0.0F);                       // The y translation
          pb.add(new InterpolationNearest()); // The interpolation
</PRE><TR valign="top"><TD><PRE>     // Create the scale operation
     im = JAI.create("scale", pb, null);
</PRE>
  <HR>

  <P><A name=61009>
  <H3>8.3.3 <IMG src="Geometric Image Manipulation.files/space.gif">Rotation 
  Transformation</H3></A>The <CODE>rotate</CODE> operation rotates an image 
  about a given point by a given angle. Specified <EM>x</EM> and <EM>y</EM> 
  values define the coordinate of the source image about which to rotate the 
  image and a rotation angle in <EM>radians</EM> defines the angle of rotation 
  about the rotation point. If no rotation point is specified, a default of 
  (0,0) is assumed. 
  <P>A negative rotation value rotates the image counter-clockwise, while a 
  positive rotation value rotates the image clockwise. 
  <P><A name=73109>
  <HR>

  <CENTER><IMG 
  src="Geometric Image Manipulation.files/Geom-image-manip.doc.ancA20.gif"></CENTER>
  <HR>
  </A><A name=73110>
  <CENTER><FONT size=-1><B><I>Figure 8-6 </I><IMG 
  src="Geometric Image Manipulation.files/sm-blank.gif" border=0> Rotate 
  Operation</B></FONT></CENTER></A>
  <P>The <CODE>rotate</CODE> operation takes one rendered or renderable source 
  image and four parameters:
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=68407>Parameters </A>
      <TH><A name=68409>Type </A>
      <TH><A name=68411>Description </A>
    <TR vAlign=top>
      <TD><A name=68413>xOrigin</A><BR>
      <TD><A name=68415>Float</A><BR>
      <TD><A name=68417>The <EM>x</EM> origin to rotate about.</A><BR>
    <TR vAlign=top>
      <TD><A name=68419>yOrigin</A><BR>
      <TD><A name=68421>Float</A><BR>
      <TD><A name=68423>The <EM>y</EM> origin to rotate about.</A><BR>
    <TR vAlign=top>
      <TD><A name=68425>angle</A><BR>
      <TD><A name=68427>Float</A><BR>
      <TD><A name=68429>The rotation angle in radians.</A><BR>
    <TR vAlign=top>
      <TD><A name=68431>interpolation</A><BR>
      <TD><A name=68433>Interpolation</A><BR>
      <TD><A name=68435>The interpolation method for resampling. One of 
        INTERP_NEAREST, INTERP_BILINEAR, INTERP_BICUBIC, or 
        INTERP_BICUBIC2.</A><BR></TR></TBODY></TABLE>
  <P>When interpolations that require padding the source such as Bilinear or 
  Bicubic interpolation are specified, the boundary of the source image needs to 
  be extended such that it has the extra pixels needed to compute all the 
  destination pixels. This extension is performed via the 
  <CODE>BorderExtender</CODE> class. The type of border extension can be 
  specified as a <CODE>RenderingHint</CODE> to the <CODE>JAI.create</CODE> 
  method. If no border extension type is provided, a default extension of 
  <CODE>BorderExtender.BORDER_COPY</CODE> will be used to perform the extension. 
  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><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Geom-image-manip.doc.html#69491">Listing 
  8-4</A> shows a code sample for a <CODE>Rotate</CODE> operation for a rotation 
  angle of 45 degrees. Since the rotation angle must be specified in radians, 
  the example first converts 45 degrees to radians.
  <P><CAPTION><FONT size=-1><B><A name=69491>
  <CENTER><FONT size=-1><B><I>Listing 8-4 </I><IMG 
  src="Geometric Image Manipulation.files/sm-blank.gif" border=0> Example Rotate 
  Operation </B></FONT></CENTER></A>
  <P></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD><PRE>     // Create the rotation a

⌨️ 快捷键说明

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