j2d
Class ShortImageBean

java.lang.Object
  extended by j2d.ImageBean
      extended by j2d.ShortImageBean
All Implemented Interfaces:
ImageBeanInterface, java.io.Serializable
Direct Known Subclasses:
FractalShortImageBean

public class ShortImageBean
extends ImageBean
implements java.io.Serializable

GPL code by DocJava, Inc. User: lyon Date: Mar 5, 2003 Time: 5:44:03 PM

See Also:
Serialized Form

Field Summary
 short[][] b
           
 Clipper clipper
           
 short[][] g
           
 short[][] r
           
 
Constructor Summary
ShortImageBean()
           
ShortImageBean(java.awt.Dimension d)
           
ShortImageBean(float[] rf, float[] gf, float[] bf, int w, int h)
           
ShortImageBean(java.awt.Image img)
           
ShortImageBean(int w, int h)
           
ShortImageBean(short[][] r, short[][] g, short[][] b)
          input a new sib and create
 
Method Summary
 void add(int n)
           
 void average(ShortImageBean sib)
          average averages the input short image bean with the given short image bean ShortImageBean sib, sib2; sib.average(sib2); This is like: a = avg(a,b);
 void buildPolygonList(int x, int y, java.awt.Polygon p)
           
 int clip(double y)
           
static short clip(int c)
           
static void clip(ShortImageBean sib)
           
 void colorErode(float[][] k)
           
 void colorToRed()
          Copy all colors to red plane, using an average operation.
 void computeGradient(int x, int y)
           
 void computeMagnitudeAndGradiant()
           
 void convolveSlow(float[][] k)
           
static ShortImageBean copy(ShortImageBean sib)
           
 void copyRedToGreenAndBlue()
           
 void divide(java.awt.Image energy)
           
static void drawHoughLineGray(ShortImageBean shortImageBean, int x, int y, short[][] s)
           
 void drawLineRed(int x1, int y1, int x2, int y2)
           
 void drawLineRed2(int x1, int y1, int x2, int y2)
           
 void drawRect(int ix, int iy, int w, int h)
           
 double getAverage()
           
 int getAverage(int x, int y)
          Get the average value of the pixels at a given location
 double getAverageB()
          Compute the average blue value
 double getAverageG()
           
 java.awt.Point getAverageLocationOfWhiteSpotAtRow(int row)
           
 double getAverageR()
           
 short[][] getB()
           
 short getBlue(int x, int y)
           
 short[] getBluePels()
           
 java.awt.Point getCentroid()
          This routine computes the centroid of all pixels that are 255 in the red plane.
 java.awt.Point getCentroid(java.awt.Rectangle rect)
          get the blob centroid of only the area inside the rectangle
 Clipper getClipper()
           
 java.awt.Point getColorLocation(double rMinusAvg, double gMinusAvg, double redRangeAvg, double gRangeAvg)
           
 java.awt.Point getColorLocation(double rOverAvg, double gOverAvg, double bOverAvg, double stdDevR, double stdDevG, double stdDevB)
           
 int getColWithLargestNumberOfWhiteSpots()
           
 java.awt.Dimension getDimension()
           
 java.io.File getFile()
           
 short[][] getG()
           
 short getGreen(int x, int y)
           
 short[] getGreenPels()
           
 double getGreenRangeAvg()
           
 int getHeight()
           
 java.awt.Image getImage()
           
 ShortImageBean getImageFlowBean()
           
 java.awt.Point getLocation()
           
 java.awt.Point getLocationOfFirstWhiteSpot()
           
 java.awt.Point getLocationOfWhiteSpotAtMaxRowAndMaxCol()
           
 java.awt.Point getLocationOfWhiteSpotAtRow(int row)
           
 MinMax2D getMinMax2DForBorder()
           
 int[] getPels()
           
 byte[] getPelsFromBlue()
           
 short[][] getR()
           
 short getRed(int x, int y)
           
 short[] getRedPels()
           
 double getRedRangeAvg()
           
 int getRowWithLargestNumberOfWhiteSpots()
           
 java.awt.Dimension getSize()
           
 double getSNRinDb(ShortImageBean sib)
           
 double getStandardDeviationOfB()
           
 double getStandardDeviationOfG()
           
 double getStandardDeviationOfR()
           
 float getTotalNoisePower(ShortImageBean sib)
           
 float getTotalSignalPower()
           
 int getWidth()
           
 void gray()
          convert the image to gray scale by taking the average of the red, green and blue colors.
 void grayPyramid(float[][] k)
           
 boolean isFromFile()
           
 boolean isInRange(double v, double x, double sigma)
           
static void linearCut(short[][] a, int numberOfBitsToCut)
           
static void main(java.lang.String[] args)
           
 void mask(ShortImageBean background)
           
 void negate()
           
 void negate2()
           
 void print()
           
 void process(HppFilterInterface hppFilter)
           
 void randImage(int min, int max)
           
static int readByte(java.io.InputStream in)
           
static char readChar(java.io.InputStream in)
           
static int readInt(java.io.InputStream in)
           
static char readNonwhiteChar(java.io.InputStream in)
           
static ShortImageBean readPpm(java.io.File fn)
           
 void reinitializeRedGreenAndBlue()
          make new instances of the internal short arrays.
 void removeTheDcComponent()
          Compute the average value for the Red, Green and Blue color plans and remove the average values from each of them.
 void resample(int ratio)
           
 void saltAndPepper(int n)
           
 void scale(int scale)
           
 void setB(short[][] b)
           
 void setClipped(boolean b)
           
 void setFile(java.io.File _f)
           
 void setFromFile(boolean fromFile)
           
 void setG(short[][] g)
           
 void setHeight(int _h)
           
 void setImage(java.awt.Image img)
           
 void setPel(int x, int y)
           
 void setPixel(int x, int y, java.awt.Color c)
           
 void setPixel(int x, int y, short red, short green, short blue)
           
 void setR(short[][] r)
           
 void setWidth(int _w)
           
 void square()
           
 void subtract(ShortImageBean sib)
          a = a - b;
static void subtract(ShortImageBean sibA, ShortImageBean sibB)
           
 void swapGreenAndBlue()
           
static void templateEdge(ShortImageBean shortImageBean, float[][] k1, float[][] k2)
           
static void test(RunVec3dPanel runVec3dPanel)
           
 void testDrawRedLine()
           
static void testZeroPadImage()
           
 void thresh(short threshValue)
           
 java.awt.Point threshCentroid(int[] fa)
           
 void threshColor(int[] fa)
           
 void threshColor4(int[] fa)
           
 short[][] trim(int dx, int dy, short[][] s)
           
 void zeroPadImage(int top, int bottom, int left, int right)
          Use the present RGB as the input, create a new RGB which will grow by top, bottom, left and right, and replace the RGB with the new values.
 
Methods inherited from class j2d.ImageBean
getColorModel, setImage
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

r

public short[][] r

g

public short[][] g

b

public short[][] b

clipper

public Clipper clipper
Constructor Detail

ShortImageBean

public ShortImageBean(java.awt.Dimension d)

ShortImageBean

public ShortImageBean()

ShortImageBean

public ShortImageBean(java.awt.Image img)

ShortImageBean

public ShortImageBean(short[][] r,
                      short[][] g,
                      short[][] b)
input a new sib and create


ShortImageBean

public ShortImageBean(int w,
                      int h)

ShortImageBean

public ShortImageBean(float[] rf,
                      float[] gf,
                      float[] bf,
                      int w,
                      int h)
Method Detail

isFromFile

public boolean isFromFile()
Specified by:
isFromFile in interface ImageBeanInterface
Overrides:
isFromFile in class ImageBean

setFromFile

public void setFromFile(boolean fromFile)
Specified by:
setFromFile in interface ImageBeanInterface
Overrides:
setFromFile in class ImageBean

setHeight

public void setHeight(int _h)
Specified by:
setHeight in interface ImageBeanInterface
Overrides:
setHeight in class ImageBean

setWidth

public void setWidth(int _w)
Specified by:
setWidth in interface ImageBeanInterface
Overrides:
setWidth in class ImageBean

getFile

public java.io.File getFile()
Specified by:
getFile in interface ImageBeanInterface
Overrides:
getFile in class ImageBean

setFile

public void setFile(java.io.File _f)
Specified by:
setFile in interface ImageBeanInterface
Overrides:
setFile in class ImageBean

test

public static void test(RunVec3dPanel runVec3dPanel)

main

public static void main(java.lang.String[] args)

testZeroPadImage

public static void testZeroPadImage()

zeroPadImage

public void zeroPadImage(int top,
                         int bottom,
                         int left,
                         int right)
Use the present RGB as the input, create a new RGB which will grow by top, bottom, left and right, and replace the RGB with the new values. The input image will be centered in the field of view. Do not use JAI for this!

Parameters:
top -
bottom -
left -
right -

getSize

public java.awt.Dimension getSize()
Returns:
the size, in pixels of the image

swapGreenAndBlue

public void swapGreenAndBlue()

getTotalNoisePower

public float getTotalNoisePower(ShortImageBean sib)

getTotalSignalPower

public float getTotalSignalPower()

getImageFlowBean

public ShortImageBean getImageFlowBean()

average

public void average(ShortImageBean sib)
average averages the input short image bean with the given short image bean ShortImageBean sib, sib2; sib.average(sib2); This is like: a = avg(a,b);

Parameters:
sib -

copy

public static ShortImageBean copy(ShortImageBean sib)

getClipper

public Clipper getClipper()

getWidth

public int getWidth()
Specified by:
getWidth in interface ImageBeanInterface
Overrides:
getWidth in class ImageBean

getHeight

public int getHeight()
Specified by:
getHeight in interface ImageBeanInterface
Overrides:
getHeight in class ImageBean

getImage

public java.awt.Image getImage()
Specified by:
getImage in interface ImageBeanInterface
Overrides:
getImage in class ImageBean

setImage

public void setImage(java.awt.Image img)
Specified by:
setImage in interface ImageBeanInterface
Overrides:
setImage in class ImageBean

gray

public void gray()
convert the image to gray scale by taking the average of the red, green and blue colors. It is silly, but fast.


colorToRed

public void colorToRed()
Copy all colors to red plane, using an average operation. ShortImageBean.colorToRed(sib); r = (r+g+b)/3;


clip

public static void clip(ShortImageBean sib)

saltAndPepper

public void saltAndPepper(int n)

add

public void add(int n)

negate

public void negate()

process

public void process(HppFilterInterface hppFilter)

negate2

public void negate2()

getLocation

public java.awt.Point getLocation()

getLocationOfWhiteSpotAtMaxRowAndMaxCol

public java.awt.Point getLocationOfWhiteSpotAtMaxRowAndMaxCol()

getAverageLocationOfWhiteSpotAtRow

public java.awt.Point getAverageLocationOfWhiteSpotAtRow(int row)

getLocationOfWhiteSpotAtRow

public java.awt.Point getLocationOfWhiteSpotAtRow(int row)

getColWithLargestNumberOfWhiteSpots

public int getColWithLargestNumberOfWhiteSpots()

getRowWithLargestNumberOfWhiteSpots

public int getRowWithLargestNumberOfWhiteSpots()

getLocationOfFirstWhiteSpot

public java.awt.Point getLocationOfFirstWhiteSpot()

getColorLocation

public java.awt.Point getColorLocation(double rOverAvg,
                                       double gOverAvg,
                                       double bOverAvg,
                                       double stdDevR,
                                       double stdDevG,
                                       double stdDevB)

isInRange

public boolean isInRange(double v,
                         double x,
                         double sigma)

getRedRangeAvg

public double getRedRangeAvg()

getGreenRangeAvg

public double getGreenRangeAvg()

getColorLocation

public java.awt.Point getColorLocation(double rMinusAvg,
                                       double gMinusAvg,
                                       double redRangeAvg,
                                       double gRangeAvg)

copyRedToGreenAndBlue

public void copyRedToGreenAndBlue()

subtract

public void subtract(ShortImageBean sib)
a = a - b;

Parameters:
sib -

clip

public static short clip(int c)

subtract

public static void subtract(ShortImageBean sibA,
                            ShortImageBean sibB)

getAverage

public int getAverage(int x,
                      int y)
Get the average value of the pixels at a given location

Parameters:
x -
y -
Returns:
average of red, green and blue

getAverageB

public double getAverageB()
Compute the average blue value

Returns:
the avg blue value

removeTheDcComponent

public void removeTheDcComponent()
Compute the average value for the Red, Green and Blue color plans and remove the average values from each of them. Call this removal of the DC Component.


getAverage

public double getAverage()

getAverageG

public double getAverageG()
Returns:
the avg green value

getAverageR

public double getAverageR()
Returns:
the avg red value

getStandardDeviationOfR

public double getStandardDeviationOfR()

getStandardDeviationOfG

public double getStandardDeviationOfG()

getStandardDeviationOfB

public double getStandardDeviationOfB()

getR

public short[][] getR()

setR

public void setR(short[][] r)

getG

public short[][] getG()

setG

public void setG(short[][] g)

getB

public short[][] getB()

setB

public void setB(short[][] b)

getPelsFromBlue

public byte[] getPelsFromBlue()

getPels

public int[] getPels()

getRedPels

public short[] getRedPels()

getBluePels

public short[] getBluePels()

getGreenPels

public short[] getGreenPels()

getSNRinDb

public double getSNRinDb(ShortImageBean sib)

linearCut

public static void linearCut(short[][] a,
                             int numberOfBitsToCut)

scale

public void scale(int scale)

readPpm

public static ShortImageBean readPpm(java.io.File fn)
                              throws java.io.IOException
Throws:
java.io.IOException

readInt

public static int readInt(java.io.InputStream in)
                   throws java.io.IOException
Throws:
java.io.IOException

readByte

public static int readByte(java.io.InputStream in)
                    throws java.io.IOException
Throws:
java.io.IOException

readNonwhiteChar

public static char readNonwhiteChar(java.io.InputStream in)
                             throws java.io.IOException
Throws:
java.io.IOException

readChar

public static char readChar(java.io.InputStream in)
                     throws java.io.IOException
Throws:
java.io.IOException

print

public void print()

setPixel

public void setPixel(int x,
                     int y,
                     java.awt.Color c)

setPixel

public void setPixel(int x,
                     int y,
                     short red,
                     short green,
                     short blue)

getMinMax2DForBorder

public MinMax2D getMinMax2DForBorder()

square

public void square()

divide

public void divide(java.awt.Image energy)

mask

public void mask(ShortImageBean background)

threshColor4

public void threshColor4(int[] fa)

colorErode

public void colorErode(float[][] k)

getCentroid

public java.awt.Point getCentroid()
This routine computes the centroid of all pixels that are 255 in the red plane. Returns null if no centroid found.

Returns:
blob centroid

threshCentroid

public java.awt.Point threshCentroid(int[] fa)

threshColor

public void threshColor(int[] fa)

drawRect

public void drawRect(int ix,
                     int iy,
                     int w,
                     int h)

setClipped

public void setClipped(boolean b)

convolveSlow

public void convolveSlow(float[][] k)

randImage

public void randImage(int min,
                      int max)

templateEdge

public static void templateEdge(ShortImageBean shortImageBean,
                                float[][] k1,
                                float[][] k2)

setPel

public void setPel(int x,
                   int y)

drawLineRed2

public void drawLineRed2(int x1,
                         int y1,
                         int x2,
                         int y2)

drawLineRed

public void drawLineRed(int x1,
                        int y1,
                        int x2,
                        int y2)

computeGradient

public void computeGradient(int x,
                            int y)

computeMagnitudeAndGradiant

public void computeMagnitudeAndGradiant()

reinitializeRedGreenAndBlue

public void reinitializeRedGreenAndBlue()
make new instances of the internal short arrays.


clip

public int clip(double y)

testDrawRedLine

public void testDrawRedLine()

trim

public short[][] trim(int dx,
                      int dy,
                      short[][] s)

resample

public void resample(int ratio)

thresh

public void thresh(short threshValue)

drawHoughLineGray

public static void drawHoughLineGray(ShortImageBean shortImageBean,
                                     int x,
                                     int y,
                                     short[][] s)

grayPyramid

public void grayPyramid(float[][] k)

buildPolygonList

public void buildPolygonList(int x,
                             int y,
                             java.awt.Polygon p)

getCentroid

public java.awt.Point getCentroid(java.awt.Rectangle rect)
get the blob centroid of only the area inside the rectangle

Parameters:
rect -
Returns:
center of mass.

getDimension

public java.awt.Dimension getDimension()

getRed

public short getRed(int x,
                    int y)

getGreen

public short getGreen(int x,
                      int y)

getBlue

public short getBlue(int x,
                     int y)