SciLib.SP.IP
Class Picture

java.lang.Object
  extended by SciLib.SP.IP.Picture

public class Picture
extends java.lang.Object

This class contains some useful methods to handle bitmap file.


Field Summary
protected  java.awt.Component c
           
 java.awt.image.ColorModel cm
           
protected  int height
           
protected  java.awt.Image image
           
protected  double[] intensities
           
protected  int[] pixels
           
protected  int width
           
 
Constructor Summary
Picture()
          make an emty constructor
Picture(java.awt.Image img, java.awt.Component c)
          make a Pict object with a specific Image img
Picture(java.lang.String fileName, java.awt.Component c)
          make a Pict object from a bitmap file
 
Method Summary
 Picture blackWhite()
          make a lack and white picture
 Picture changeIntensities(int p)
          change intensities
 Picture contrast(int t, int t2, java.lang.String color)
          make a contrast picture
 Picture crop(int x, int y, int w, int h)
          crop an image with a specific rectangle
 Picture crop(java.awt.Rectangle rect)
          crop an image with a specific rectangle
 Picture dissolve(int alpha)
          Alpha filter an image with a media tracker in a component c
 void drawImage(java.awt.Graphics g)
          draw image
 void drawImage(java.awt.Graphics g, int w, int h)
          draw image
 Picture edge()
          make an edge picture
 int[] getColors(java.lang.String color)
          get color components of a picture
 int getHeight()
          get height
 java.awt.Image getImage()
          get image
 double[] getIntensities()
          get intensities
 double getIntensity(int rgb)
          get Intensity
 int getPixel(int i)
          get pixel at index i
 int getPixel(int x, int y)
          gets a pixel at (x,y)
 int[] getPixels()
          get pixels
 int getWidth()
          get width
 int[] iHistogram()
          intenisty histogram
static int[] makeHistogram(int[] col)
          make histogram
 Picture makePicture(int width, int height, int[] pixels)
          make a picture from an array of pixels
 Picture negative()
          make a negative picture
 Picture scale(double ws, double hs)
          scale an image with with a media tracker in a component c
 Picture scaleColor(int r, int g, int b)
          scale all colors in the picture
 Picture scaleColor(int p, java.lang.String color)
          scale one or all color components in the picture
 void setHeight(int h)
          set heigth
 void setPixels(int[] p)
          set pixels
 void setWidth(int w)
          set width
 Picture shadow()
          make a shadow picture
 Picture waveFilter(int amplitude, int frequency)
          make a wave filter picture
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pixels

protected int[] pixels

intensities

protected double[] intensities

image

protected java.awt.Image image

width

protected int width

height

protected int height

cm

public java.awt.image.ColorModel cm

c

protected java.awt.Component c
Constructor Detail

Picture

public Picture()
make an emty constructor


Picture

public Picture(java.awt.Image img,
               java.awt.Component c)
make a Pict object with a specific Image img


Picture

public Picture(java.lang.String fileName,
               java.awt.Component c)
make a Pict object from a bitmap file

Method Detail

getWidth

public int getWidth()
get width

Returns:
A integer value

getHeight

public int getHeight()
get height

Returns:
A integer value

getImage

public java.awt.Image getImage()
get image

Returns:
An image object

getPixel

public int getPixel(int i)
get pixel at index i

Parameters:
i - An integer value
Returns:
An integer value

getPixel

public int getPixel(int x,
                    int y)
gets a pixel at (x,y)

Parameters:
x - An integer value
y - An integer value
Returns:
An integer value

getPixels

public int[] getPixels()
get pixels

Returns:
An integer array

setWidth

public void setWidth(int w)
set width


setHeight

public void setHeight(int h)
set heigth


setPixels

public void setPixels(int[] p)
set pixels


drawImage

public void drawImage(java.awt.Graphics g)
draw image


drawImage

public void drawImage(java.awt.Graphics g,
                      int w,
                      int h)
draw image


crop

public Picture crop(int x,
                    int y,
                    int w,
                    int h)
crop an image with a specific rectangle

Parameters:
x - An integer, x position
y - An integer, y position
w - An integer, the width of the rectangle
h - An integer, the height of the rectangle
Returns:
A Picture object

crop

public Picture crop(java.awt.Rectangle rect)
crop an image with a specific rectangle

Parameters:
rect - A Rectabgle area
Returns:
A Picture object

scale

public Picture scale(double ws,
                     double hs)
scale an image with with a media tracker in a component c

Parameters:
ws - A double value, the horizontal scale factor
hs - A double value, the vertical scale factor
Returns:
A Picture object

dissolve

public Picture dissolve(int alpha)
Alpha filter an image with a media tracker in a component c

Parameters:
alpha - An integer value, the alpha value between 0 and 255
Returns:
A Picture object

blackWhite

public Picture blackWhite()
make a lack and white picture

Returns:
A Picture object

negative

public Picture negative()
make a negative picture

Returns:
A Picture object

contrast

public Picture contrast(int t,
                        int t2,
                        java.lang.String color)
make a contrast picture

Parameters:
t - An integer value, a threshold
Returns:
A Picture object

scaleColor

public Picture scaleColor(int r,
                          int g,
                          int b)
scale all colors in the picture

Parameters:
r - An integer value, the percentage of the red component
g - An integer value, the percentage of the green component
b - An integer value, the percentage of the blue component
Returns:
A Picture object

scaleColor

public Picture scaleColor(int p,
                          java.lang.String color)
scale one or all color components in the picture

Parameters:
p - An integer value, the percentage of the color component
color - A String, the color component, "red", "green", "blue" or "all"
Returns:
A Picture object

makePicture

public Picture makePicture(int width,
                           int height,
                           int[] pixels)
make a picture from an array of pixels

Parameters:
width - An integer, the width of the picture
height - An integer, the height of the picture
pixels - An integer array

waveFilter

public Picture waveFilter(int amplitude,
                          int frequency)
make a wave filter picture

Parameters:
amplitude - An integer value
frequency - An integer value
Returns:
A Picture object

shadow

public Picture shadow()
make a shadow picture

Returns:
A Picture object

getIntensity

public double getIntensity(int rgb)
get Intensity

Returns:
A double value

getIntensities

public double[] getIntensities()
get intensities

Returns:
A double array

edge

public Picture edge()
make an edge picture

Returns:
A Picture object

iHistogram

public int[] iHistogram()
intenisty histogram

Returns:
An integer array

getColors

public int[] getColors(java.lang.String color)
get color components of a picture

Returns:
An integer array

makeHistogram

public static int[] makeHistogram(int[] col)
make histogram

Returns:
An integer array

changeIntensities

public Picture changeIntensities(int p)
change intensities