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
           
 java.lang.String dir
           
 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 adaptiveHistogramEqualization(int blocksHigh, int blocksWide)
           
 void add(int n)
           
 void add(ShortImageBean sib)
           
 void assembleMosaic(java.awt.Image subImage, int x1, int y1)
           
 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)
           
 void clearLow34()
           
 void clearLowHalf()
           
 void clearQ1()
           
 void clearq2()
           
 void clearRect(int x1, int y1, int x2, int y2)
           
static void clearRect(ShortImageBean shortImageBean, int x1, int y1, int x2, int y2)
           
 int clip(double y)
           
static short clip(int c)
           
static void clip(ShortImageBean sib)
           
 void clp()
           
 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()
           
 java.awt.Image cropImage(java.awt.Point min, java.awt.Point max)
          Crop the image in the SIB to the size of min and max ImageUtils has a better crop implementation
 int cx(int x)
           
 int cy(int y)
           
 void divide(java.awt.Image energy)
           
 void divide(int n)
           
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)
           
 void freiChen()
           
 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)
           
 java.awt.Point[] getAverageLocationsOfWhiteSpotsAtEachRow(int threshR)
           
 double getAverageR()
          Obtained by summing the 2D array and dividing by the number of elements.
 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.lang.String getDir()
           
 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()
           
 int getLocationOfNonWhiteSpotAtRowFromRightToLeft(int y)
           
 java.awt.Point getLocationOfWhiteSpotAtMaxRowAndMaxCol()
           
 java.awt.Point getLocationOfWhiteSpotAtRow(int row)
           
 MinMax2D getMinMax2DForBorder()
           
 float getMse(ShortImageBean sib)
           
 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()
           
 java.awt.Point[] getTheBrightestSpotForEachColumnLeftToRight()
           
 java.awt.Point[] getTheBrightestSpotForEachColumnRightToLeft()
           
 java.awt.Point[] getTheBrightestSpotForEachRow()
           
 float getTotalNoisePower(ShortImageBean sib)
           
 float getTotalSignalPower()
          Compute the total signal power by adding all the r,g,b values, squaring.
 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)
           
 void grbNumImg()
           
 boolean isEqual(int x, int y, int value)
           
 boolean isFromFile()
           
 boolean isInRange(double v, double x, double sigma)
           
static void linearCut(short[][] a, int numberOfBitsToCut)
           
static void linearTransform(double c, double br, ShortImageBean b)
           
static void main(java.lang.String[] args)
           
 void mask(ShortImageBean background)
           
 void multiplyRed(ShortImageBean sib)
          r = r * sib.getR();
 void negate()
           
 void negate2()
           
 void pixelDifference()
           
static void powImage(ImageFrame ifi, ShortImageBean nf, double p)
           
 void prewitt()
           
 void print()
           
 void process(HppFilterInterface hppFilter)
           
 void randImage(int min, int max)
           
 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 roberts2()
           
 void saltAndPepper(int n)
           
 void scale(int scale)
           
 void setB(short[][] b)
           
 void setBlue(int x, int y, short blue)
           
 void setClipped(boolean b)
           
 void setDir(java.lang.String dir)
           
 void setFile(java.io.File _f)
           
 void setFromFile(boolean fromFile)
           
 void setG(short[][] g)
           
 void setGreen(int x, int y, short green)
           
 void setHeight(int _h)
           
 void setImage(java.awt.Image img)
           
 void setImage(ShortImageBean window, java.awt.Rectangle re)
           
 void setPel(int x, int y)
           
 void setPixel(int x, int y, java.awt.Color c)
           
 void setPixel(int x, int y, int red, int green, int blue)
           
 void setPixel(int x, int y, short red, short green, short blue)
           
 void setR(short[][] r)
           
 void setRed(int x, int y, short red)
           
 void setRGBPels(byte[] rp, byte[] gp, byte[] bp)
           
 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 turn90()
           
 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

dir

public java.lang.String dir
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

Parameters:
r - 2d array of short
g - 2d array of short
b - 2D array of short

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

turn90

public void turn90()

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)

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 - the size of the top pad
bottom - the size of the bottom pad
left - the size of the left pad
right - the size of the right pad

getSize

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

swapGreenAndBlue

public void swapGreenAndBlue()

getMse

public float getMse(ShortImageBean sib)

getTotalNoisePower

public float getTotalNoisePower(ShortImageBean sib)

getTotalSignalPower

public float getTotalSignalPower()
Compute the total signal power by adding all the r,g,b values, squaring. Assume that we do no have negative values and that the sum will be less than the maximum value of a float.

Returns:
squares sum of r+g+b

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 - the other image to average against

add

public void add(ShortImageBean 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()

getAverageLocationsOfWhiteSpotsAtEachRow

public java.awt.Point[] getAverageLocationsOfWhiteSpotsAtEachRow(int threshR)

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 - the x coordinate to obtain the average
y - the y coordinate to objain the average
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()
Obtained by summing the 2D array and dividing by the number of elements.

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()

setRGBPels

public void setRGBPels(byte[] rp,
                       byte[] gp,
                       byte[] bp)

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)

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)

setPixel

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

getMinMax2DForBorder

public MinMax2D getMinMax2DForBorder()

square

public void square()

divide

public void divide(int n)

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 - get the center of the rectangle
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)

setImage

public void setImage(ShortImageBean window,
                     java.awt.Rectangle re)

multiplyRed

public void multiplyRed(ShortImageBean sib)
r = r * sib.getR();

Parameters:
sib - the other image

getTheBrightestSpotForEachRow

public java.awt.Point[] getTheBrightestSpotForEachRow()

getTheBrightestSpotForEachColumnRightToLeft

public java.awt.Point[] getTheBrightestSpotForEachColumnRightToLeft()

getTheBrightestSpotForEachColumnLeftToRight

public java.awt.Point[] getTheBrightestSpotForEachColumnLeftToRight()

clp

public void clp()

clearLow34

public void clearLow34()

clearLowHalf

public void clearLowHalf()

clearq2

public void clearq2()

clearQ1

public void clearQ1()

clearRect

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

cy

public int cy(int y)

cx

public int cx(int x)

grbNumImg

public void grbNumImg()

clearRect

public static void clearRect(ShortImageBean shortImageBean,
                             int x1,
                             int y1,
                             int x2,
                             int y2)

getDir

public java.lang.String getDir()

setDir

public void setDir(java.lang.String dir)

cropImage

public java.awt.Image cropImage(java.awt.Point min,
                                java.awt.Point max)
Crop the image in the SIB to the size of min and max ImageUtils has a better crop implementation

Parameters:
min - the upper left corner
max - the lower right corner
Returns:
the cropped image

freiChen

public void freiChen()

pixelDifference

public void pixelDifference()

prewitt

public void prewitt()

roberts2

public void roberts2()

main

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

isEqual

public boolean isEqual(int x,
                       int y,
                       int value)

getLocationOfNonWhiteSpotAtRowFromRightToLeft

public int getLocationOfNonWhiteSpotAtRowFromRightToLeft(int y)

powImage

public static void powImage(ImageFrame ifi,
                            ShortImageBean nf,
                            double p)

linearTransform

public static void linearTransform(double c,
                                   double br,
                                   ShortImageBean b)

assembleMosaic

public void assembleMosaic(java.awt.Image subImage,
                           int x1,
                           int y1)

adaptiveHistogramEqualization

public void adaptiveHistogramEqualization(int blocksHigh,
                                          int blocksWide)

setRed

public void setRed(int x,
                   int y,
                   short red)

setGreen

public void setGreen(int x,
                     int y,
                     short green)

setBlue

public void setBlue(int x,
                    int y,
                    short blue)