Download presentation
Presentation is loading. Please wait.
1
Manipulating and Displaying Images in Java Lihang Ying Department of Computing Science University of Alberta, Canada 2005-1-25
2
Display an image Image img = getImage(getURL("images/test.jpg")); BufferedImage bi = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB); Graphics2D big = bi.createGraphics(); big.drawImage(img,0,x,y);
3
Manipulate pixels Class BufferedImage int getRGB(int x, int y)getRGB void setRGB(int x, int y, int rgb)setRGB void setData(Raster r) Sets a rectangular region of the image to the contents of the specified Raster r.setDataRaster Class WritableRaster extend Raster A class representing a rectangular array of pixels. voidsetPixel(int x, int y, float[] fArray)setPixel …
4
Image-filter operations(1)
5
Image-Filter Operations(2) public static final float[] SHARPEN3x3 = { 0.f, -1.f, 0.f, -1.f, 5.0f, -1.f, 0.f, -1.f, 0.f}; BufferedImage dstbimg = new BufferedImage(iw,ih,BufferedImage.TYPE_INT_R GB); Kernel kernel = new Kernel(3,3,SHARPEN3x3); ConvolveOp cop = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); cop.filter(srcbimg,dstbimg);
6
References Tutorial http://java.sun.com/docs/books/tutorial/2d/images/index.html http://www.vet.purdue.edu/java/docs/guide/2d/spec/j2d- image.fm.html#65661 http://www.vet.purdue.edu/java/docs/guide/2d/spec/j2d- image.fm.html#65661 Java API http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/awt/i mage/BufferedImage.html http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/awt/i mage/BufferedImage.html http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/awt/i mage/Raster.html http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/awt/i mage/Raster.html
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.