JSci.Demos.wavelet
Class PixelArray

java.lang.Object
  extended by JSci.Demos.wavelet.PixelArray
All Implemented Interfaces:
java.awt.image.ImageObserver

public final class PixelArray
extends java.lang.Object
implements java.awt.image.ImageObserver

This is a simple implementation of the PixelGrabber class to allow for easier image processing. Basically, it reads a graphic file and allows you to get integer arrays from it for convenient processing. The name of the class comes from the fact that the image is stored as an internal int[][] array. This might seem inefficient since the JDK stores images as an int[] array and that we must go back and forth between the two formats. It is indeed slower, but as far as image processing is concerned, it is much simpler to work with an int[][] array. Moreover, if the processing is moderatly involved, it won't make much difference.

Author:
Daniel Lemire

Field Summary
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PixelArray(double[][] D)
           
PixelArray(int[][] I)
           
PixelArray(java.lang.String filename)
          Constructor
PixelArray(java.net.URL url)
          Constructor
 
Method Summary
 PixelArray[][] blueFWT(Multiresolution m)
          Fast Wavelet Transform This method assumes a dyadic multiresolution.
static java.awt.Image buildImage(int[][] a)
           
 java.lang.Object clone()
           
 int getAlpha(int x, int y)
           
 int[][] getAlphaArray(int x, int y)
           
 int[][] getArray(int x, int y)
           
 int getBlue(int x, int y)
           
 int[][] getBlueArray()
           
 int getGreen(int x, int y)
           
 int[][] getGreenArray()
           
 int getHeight()
           
 int getRed(int x, int y)
           
 int[][] getRedArray()
           
 int getWidth()
           
 PixelArray[][] greenFWT(Multiresolution m)
          Fast Wavelet Transform This method assumes a dyadic multiresolution.
 boolean imageUpdate(java.awt.Image img1, int parm2, int parm3, int parm4, int parm5, int parm6)
          Part of the interface ImageObserver
 void invert()
           
 void makeBlue()
           
 void makeGrayFromBlue()
           
 void makeGrayFromGreen()
           
 void makeGrayFromRed()
           
 void makeGreen()
           
 void makeRed()
           
 java.awt.Image rebuildImage()
          Get the image back
 PixelArray[][] redFWT(Multiresolution m)
          Fast Wavelet Transform This method assumes a dyadic multiresolution.
static int RGBtoInt(int r, int g, int b, int a)
           
 void setAlphaArray(int[][] I)
           
 void setArray(int[][] s)
          Allow to change the array representing the image
 void setBlueArray(int[][] I)
           
 void setGreenArray(int[][] I)
           
 void setPixel(int x, int y, int r, int g, int b, int a)
           
 void setRedArray(int[][] I)
           
 void waitForImage(java.awt.Image img)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PixelArray

public PixelArray(java.lang.String filename)
Constructor

Parameters:
filename - file containing the image
Throws:
java.lang.IllegalArgumentException - if the file can't be open. Either the format is wrong or the file cannot be found.

PixelArray

public PixelArray(java.net.URL url)
Constructor

Parameters:
filename - file containing the image
Throws:
java.lang.IllegalArgumentException - if the file can't be open. Either the format is wrong or the file cannot be found.

PixelArray

public PixelArray(int[][] I)

PixelArray

public PixelArray(double[][] D)
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getWidth

public int getWidth()

getHeight

public int getHeight()

setRedArray

public void setRedArray(int[][] I)

setGreenArray

public void setGreenArray(int[][] I)

setBlueArray

public void setBlueArray(int[][] I)

setAlphaArray

public void setAlphaArray(int[][] I)

imageUpdate

public boolean imageUpdate(java.awt.Image img1,
                           int parm2,
                           int parm3,
                           int parm4,
                           int parm5,
                           int parm6)
Part of the interface ImageObserver

Specified by:
imageUpdate in interface java.awt.image.ImageObserver

waitForImage

public void waitForImage(java.awt.Image img)

RGBtoInt

public static int RGBtoInt(int r,
                           int g,
                           int b,
                           int a)

invert

public void invert()

makeGrayFromRed

public void makeGrayFromRed()

makeGrayFromGreen

public void makeGrayFromGreen()

makeGrayFromBlue

public void makeGrayFromBlue()

makeRed

public void makeRed()

makeGreen

public void makeGreen()

makeBlue

public void makeBlue()

setPixel

public void setPixel(int x,
                     int y,
                     int r,
                     int g,
                     int b,
                     int a)

setArray

public void setArray(int[][] s)
Allow to change the array representing the image

Throws:
java.lang.IllegalArgumentException - if array doesn't make a matrix

getRed

public int getRed(int x,
                  int y)

getGreen

public int getGreen(int x,
                    int y)

getBlue

public int getBlue(int x,
                   int y)

getAlpha

public int getAlpha(int x,
                    int y)

getRedArray

public int[][] getRedArray()

getGreenArray

public int[][] getGreenArray()

getBlueArray

public int[][] getBlueArray()

getAlphaArray

public int[][] getAlphaArray(int x,
                             int y)

getArray

public int[][] getArray(int x,
                        int y)

redFWT

public PixelArray[][] redFWT(Multiresolution m)
Fast Wavelet Transform This method assumes a dyadic multiresolution. This implementation is temporary, expect it to be slow. It is meant to be easily understood. One good thing about this method is that it will handle the boundary automatically (as long as the chosen Multiresolution handles them). Also, it will work with any Multiresolution object. Only the red component is treated.


greenFWT

public PixelArray[][] greenFWT(Multiresolution m)
Fast Wavelet Transform This method assumes a dyadic multiresolution. This implementation is temporary, expect it to be slow. It is meant to be easily understood. One good thing about this method is that it will handle the boundary automatically (as long as the chosen Multiresolution handles them). Also, it will work with any Multiresolution object. Only the green component is treated.


blueFWT

public PixelArray[][] blueFWT(Multiresolution m)
Fast Wavelet Transform This method assumes a dyadic multiresolution. This implementation is temporary, expect it to be slow. It is meant to be easily understood. One good thing about this method is that it will handle the boundary automatically (as long as the chosen Multiresolution handles them). Also, it will work with any Multiresolution object. Only the blue component is treated.


rebuildImage

public java.awt.Image rebuildImage()
Get the image back


buildImage

public static java.awt.Image buildImage(int[][] a)