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

📄 image manipulation.htm

📁 是一部关于java高级图像处理的的一本入门书
💻 HTM
📖 第 1 页 / 共 5 页
字号:
     RenderedOp im0 = JAI.create("constant", param1);
     RenderedOp im1 = JAI.create("constant", param2);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top"><TD><PRE>     // Find the maximum value of the two images
     RenderedOp im2 = JAI.create("max", im0, im1);
</PRE>
  <HR>

  <P><A name=58446>
  <H3>6.3.2 <IMG src="Image Manipulation.files/space.gif">Finding the Minimum 
  Values of Two Images</H3></A>The <CODE>min</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 minimum 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] &lt; 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>min</CODE> operation takes two rendered source images and no 
  parameters. <A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Image-manipulation.doc.html#70445">Listing 
  6-2</A> shows a partial code sample of computing the pixelwise minimum value 
  of two images in the renderable mode.
  <P><CAPTION><FONT size=-1><B><A name=70445>
  <CENTER><FONT size=-1><B><I>Listing 6-2 </I><IMG 
  src="Image Manipulation.files/sm-blank.gif" border=0> Finding the Minimum 
  Value of Two Images</B></FONT></CENTER></A>
  <P></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD rowspan="7" colspan="1"><PRE>     // Set up the parameter block and add the two source images to it
     ParameterBlock pb = new ParameterBlock();
     pb.add(im0);
     pb.add(im1);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top"><TR valign="top"><TD><PRE>     // Find the maximum value of the two images
     RenderableOp im2 = JAI.createRenderable("min", pb, hints);
</PRE>
  <HR>

  <P><A name=58465>
  <H2>6.4 <IMG src="Image Manipulation.files/space.gif">Logical 
  Operators</H2></A>JAI supports <EM>monadic</EM>, <EM>dyadic</EM>, and 
  <EM>unary</EM> logical operators. The monadic logical operations include 
  pixel-by-pixel AND, OR, and XOR operations between a source image and a 
  constant to produce a destination image. The dyadic logical operations include 
  pixel-by-pixel AND, OR, and XOR operations between two source images to 
  produce a destination image. The unary logical operation is a NOT operation 
  (complement image) on each pixel of a source image on a per-band basis. 
  <P>JAI supports the following logical operations: 
  <P>
  <UL>
    <LI>Take the bitwise AND of the two source images and store the results in 
    the destination (<CODE>And</CODE>)
    <P></P></LI></UL>
  <UL>
    <LI>Take the bitwise AND of a source image and one of a set of per-band 
    constants (<CODE>AndConst</CODE>)
    <P></P></LI></UL>
  <UL>
    <LI>Take the bitwise OR of the two source images and store the results in 
    the destination (<CODE>Or</CODE>)
    <P></P></LI></UL>
  <UL>
    <LI>Take the bitwise OR of a source image and one of a set of per-band 
    constants (<CODE>OrConst</CODE>)
    <P></P></LI></UL>
  <UL>
    <LI>Take the bitwise XOR (exclusiveOR) of the two source images and store 
    the results in the destination (<CODE>Xor</CODE>)
    <P></P></LI></UL>
  <UL>
    <LI>Take the bitwise XOR of a source image and one of a set of per-band 
    constants (<CODE>XorConst</CODE>)
    <P></P></LI></UL>
  <UL>
    <LI>Take the bitwise NOT of a source image on each pixel on a per-band basis 
    (<CODE>Not</CODE>)
    <P></P></LI></UL>As with the relational operators, the logical operations 
  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><A name=56569>
  <H3>6.4.1 <IMG src="Image Manipulation.files/space.gif">ANDing Two 
  Images</H3></A>The <CODE>And</CODE> operation takes two rendered or renderable 
  source images, and performs a bit-wise logical AND on every pair of pixels, 
  one from each source image, of the corresponding position and band. 
  <P>Both source images must have integral data types. The two data types may be 
  different. 
  <P>Unless altered by an <CODE>ImageLayout</CODE> hint, the destination image 
  bound is the intersection of the two source image bounds. If the two sources 
  don't intersect, the destination will have a width and height of 0. The number 
  of bands of the destination image is equal to the lesser number of bands of 
  the source images, and the data type is the smallest data type with sufficient 
  range to cover the range of both source data types. 
  <P>The following matrix defines the logical <CODE>And</CODE> operation.
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=56613>src0 </A>
      <TH><A name=56615>src1 </A>
      <TH><A name=56617>Result </A>
    <TR vAlign=top>
      <TD><A name=56619>0</A><BR>
      <TD><A name=56621>0</A><BR>
      <TD><A name=56623>0</A><BR>
    <TR vAlign=top>
      <TD><A name=56625>0</A><BR>
      <TD><A name=56627>1</A><BR>
      <TD><A name=56629>0</A><BR>
    <TR vAlign=top>
      <TD><A name=56631>1</A><BR>
      <TD><A name=56633>0</A><BR>
      <TD><A name=56635>0</A><BR>
    <TR vAlign=top>
      <TD><A name=56637>1</A><BR>
      <TD><A name=56639>1</A><BR>
      <TD><A name=56641>1</A><BR></TR></TBODY></TABLE>
  <P>The destination pixel values are defined by the following pseudocode: 
  <P><PRE>     dst[x][y][b] = srcs[0][x][y][b] &amp; srcs[1][x][y][b];
</PRE>The <CODE>And</CODE> operation takes two rendered or renderable source 
  images and no parameters. 
  <P><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Image-manipulation.doc.html#70476">Listing 
  6-3</A> shows a partial code sample of using the <CODE>And</CODE> operation to 
  AND two images together.
  <P><CAPTION><FONT size=-1><B><A name=70476>
  <CENTER><FONT size=-1><B><I>Listing 6-3 </I><IMG 
  src="Image Manipulation.files/sm-blank.gif" border=0> ANDing Two 
  Images</B></FONT></CENTER></A>
  <P></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD rowspan="7" colspan="1"><PRE>     // Set up the parameter block and add the two source images to it.
     ParameterBlock pb = new ParameterBlock();
     pb.addSource(im0);          // The first image
     pb.addSource(im1);          // The second image
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top"><TR valign="top"><TD><PRE>     // AND the two images together.
     RenderableOp op = JAI.createRenderable("and", pb, hints);
</PRE>
  <HR>

  <P><A name=56421>
  <H3>6.4.2 <IMG src="Image Manipulation.files/space.gif">ANDing an Image with a 
  Constant</H3></A>The <CODE>AndConst</CODE> operation takes one rendered or 
  renderable image and an array of integer constants, and performs a bit-wise 
  logical AND between every pixel in the same band of the source and the 
  constant from the corresponding array entry. If the number of constants 
  supplied is less than the number of bands of the destination, then the 
  constant from entry 0 is applied to all the bands. Otherwise, a constant from 
  a different entry is applied to each band. 
  <P>The source image must have an integral data type. By default, the 
  destination image bound, data type, and number of bands are the same as the 
  source image. 
  <P>The following matrix defines the logical <CODE>AndConst</CODE> operation:
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=57569>src </A>
      <TH><A name=57571>const </A>
      <TH><A name=57573>Result </A>
    <TR vAlign=top>
      <TD><A name=57575>0</A><BR>
      <TD><A name=57577>0</A><BR>
      <TD><A name=57579>0</A><BR>
    <TR vAlign=top>
      <TD><A name=57581>0</A><BR>
      <TD><A name=57583>1</A><BR>
      <TD><A name=57585>0</A><BR>
    <TR vAlign=top>
      <TD><A name=57587>1</A><BR>
      <TD><A name=57589>0</A><BR>
      <TD><A name=57591>0</A><BR>
    <TR vAlign=top>
      <TD><A name=57593>1</A><BR>
      <TD><A name=57595>1</A><BR>
      <TD><A name=57597>1</A><BR></TR></TBODY></TABLE>
  <P>The destination pixel values are defined by the following pseudocode: 
  <P><PRE>     if (constants.length &lt; dstNumBands) {
         dst[x][y][b] = srcs[x][y][b] &amp; constants[0];
     } else {
         dst[x][y][b] = srcs[x][y][b] &amp; constants[b];
     }
</PRE>The <CODE>AndConst</CODE> operation takes one rendered or renderable 
  source image and one parameter:
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=59369>Parameter </A>
      <TH><A name=59371>Type </A>
      <TH><A name=59373>Description </A>
    <TR vAlign=top>
      <TD><A name=59375>constants</A><BR>
      <TD><A name=59377>int</A><BR>
      <TD><A name=59379>The per-band constants to logically AND 
    with.</A><BR></TR></TBODY></TABLE>
  <P><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Image-manipulation.doc.html#70503">Listing 
  6-4</A> shows a partial code sample of using the <CODE>AndConst</CODE> 
  operation to AND a source image with a defined constant of value 1.2.
  <P><CAPTION><FONT size=-1><B><A name=70503>
  <CENTER><FONT size=-1><B><I>Listing 6-4 </I><IMG 
  src="Image Manipulation.files/sm-blank.gif" border=0> ANDing an Image with a 
  Constant</B></FONT></CENTER></A>
  <P></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD rowspan="8" colspan="1"><PRE>     // Set up the parameter block with the source and a constant
     // value.
     ParameterBlock pb = new ParameterBlock();
     pb.addSource(im);       // im as the source image
     pb.add(1.2f);     // The constant
     
     // AND the image with the constant.
     RenderableOp op = JAI.createRenderable("andconst", pb, hints);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top"><TR valign="top">
  <HR>

  <P><A name=61460>
  <H3>6.4.3 <IMG src="Image Manipulation.files/space.gif">ORing Two 
  Images</H3></A>The <CODE>Or</CODE> operation takes two rendered or renderable 
  images, and performs a bit-wise logical OR on every pair of pixels, one from 
  each source image of the corresponding position and band. 
  <P>Both source images must have integral data types. The two data types may be 
  different. 
  <P>Unless altered by an <CODE>ImageLayout</CODE> hint, the destination image 
  bound is the intersection of the two source image bounds. If the two sources 
  don't intersect, the destination will have a width and height of 0. The number 
  of bands of the destination image is equal to the lesser number of bands of 
  the source images, and the data type is the smallest data type with sufficient 
  range to cover the range of both source data types. 
  <P>The following matrix defines the logical <CODE>OR</CODE> operation:
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=59692>src0 </A>
      <TH><A name=59694>src1 </A>
      <TH><A name=59696>Result </A>
    <TR vAlign=top>
      <TD><A name=59698>0</A><BR>
      <TD><A name=59700>0</A><BR>
      <TD><A name=59702>0</A><BR>
    <TR vAlign=top>
      <TD><A name=59704>0</A><BR>
      <TD><A name=59706>1</A><BR>
      <TD><A name=59708>1</A><BR>
    <TR vAlign=top>
      <TD><A name=59710>1</A><BR>
      <TD><A name=59712>0</A><BR>
      <TD><A name=59714>1</A><BR>
    <TR vAlign=top>
      <TD><A name=59716>1</A><BR>
      <TD><A name=59718>1</A><BR>
      <TD><A name=59720>1</A><BR></TR></TBODY></TABLE>
  <P>The destination pixel values are defined by the following pseudocode: 
  <P><PRE>     dst[x][y][b] = srcs[0][x][y][b] | srcs[1][x][y][b];
</PRE>The <CODE>Or</CODE> operation takes two rendered or renderable source 
  images and no parameters. 
  <P><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Image-manipulation.doc.html#70533">Listing 
  6-5</A> shows a partial code sample of using the <CODE>or</CODE> operation to 
  OR two images.
  <P><CAPTION><FONT size=-1><B><A name=70533>
  <CENTER><FONT size=-1><B><I>Listing 6-5 </I><IMG 
  src="Image Manipulation.files/sm-blank.gif" border=0> ORing Two Images 
  </B></FONT></CENTER></A>
  <P></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD rowspan="5" colspan="1"><PRE>     // Read the first image.
     pb = new ParameterBlock();
     pb.addSource(file1);
     RenderedOp src1 = JAI.create("stream", pb);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TD rowspan="4" colspan="1"><PRE>     // Read the second image.
     pb = new ParameterBlock();
     pb.addSource(file2);
     RenderedImage src2 = JAI.create("stream", pb);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TD 
  rowspan="3" colspan="1"><PRE>     // OR the two images.
     RenderedOp dst = JAI.create("or", src1, src2);
</PRE><TR valign="top"><TR valign="top">
  <HR>

  <P><A name=58466>
  <H3>6.4.4 <IMG src="Image Manipulation.files/space.gif">ORing an Image with a 
  Constant</H3></A>The <CODE>OrConst</CODE> operation takes one rendered or 
  renderable image and an array of integer constants, and performs a bit-wise 
  logical OR between every pixel in the same band of the source image and the 
  constant from the corresponding array entry. If the number of constants 
  supplied is less than the number of bands of the destination, the constant 
  from entry 0 is applied to all the bands. Otherwise, a constant from a 
  different entry is applied to each band. 
  <P>The source image must have an integral data type. By default, the 
  destination image bound, data type, and number of bands are the same as the 
  source image. 
  <P>The following matrix defines the logical <CODE>OrConst</CODE> operation:
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=71957>src </A>
      <TH><A name=71959>const </A>
      <TH><A name=71961>Result </A>
    <TR vAlign=top>
      <TD><A name=71963>0</A><BR>
      <TD><A name=71965>0</A><BR>
      <TD><A name=71967>0</A><BR>
    <TR vAlign=top>
      <TD><A name=71969>0</A><BR>
      <TD><A name=71971>1</A><BR>
      <TD><A name=71973>1</A><BR>
    <TR vAlign=top>
      <TD><A name=71975>1</A><BR>
      <TD><A name=71977>0</A><BR>
      <TD><A name=71979>1</A><BR>
    <TR vAlign=top>
      <TD><A name=71981>1</A><BR>
      <TD><A name=71983>1</A><BR>
      <TD><A name=71985>1</A><BR></TR></TBODY></TABLE>
  <P>The destination pixel values are defined by the following pseudocode: 
  <P><PRE>     if (constants.length &lt; dstNumBands) {
         dst[x][y][b] = src[x][y][b] | c

⌨️ 快捷键说明

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