JIGL
v1.6

jigl.image
Class BinaryImage

java.lang.Object
  |
  +--jigl.image.BinaryImage
All Implemented Interfaces:
Image

public class BinaryImage
extends Object
implements Image

BinaryImage is implrmented by a 2-d array of byte. All the values in a BinaryImage are either 1(white) or 0(black).


Field Summary
protected  byte[][] data
          Two dimensional byte array
protected  int X
          Cartesian width
protected  int Y
          Cartesian height
 
Constructor Summary
BinaryImage()
          Creates an empty two dimensional BinaryImage with a height and width of zero
BinaryImage(BinaryImage image)
          Creates a two dimensional BinaryImage (shallow copy of data) from image.
BinaryImage(byte[][] data)
          Creates a BinaryImage from data.
BinaryImage(GrayImage image)
          Creates a two dimensional BinaryImage from a GrayImage.
BinaryImage(int x, int y)
          Creates a two dimensional BinaryImage with a width and height of x and y repectively
BinaryImage(int x, int y, byte[] data)
          Creates a two dimensional BinaryImage with a width and height of x and y repectively.
BinaryImage(RealGrayImage image)
          Creates a two dimensional BinaryImage from a RealGrayImage.
 
Method Summary
 BinaryImage compliment()
          Computes the complement of this image
 Image copy()
          Makes a deep copy of this image
 Image copy(ROI roi)
          Makes a deep copy of this image in a Region of Interest
 int count()
          Counts the number of "on" pixels
 BinaryImage difference(BinaryImage image)
          Returns the difference of this image and a BinaryImage
 byte get(int x, int y)
          Returns the pixel value at the given x, y value
 byte[][] getData()
          Returns a deep copy of the image data.
 ImageProducer getJavaImage()
          Gets the JavaImage from a JiglImage
 BinaryImage intersection(BinaryImage image)
          Finds the intersection between this image and another BinaryImage.
 void set(int x, int y, int value)
          Sets the pixel value at x, y to a given value
 BinaryImage shift(int horizonal, int vertical)
          Performs a shift on this image with out wrap.
 BinaryImage union(BinaryImage image)
          Finds the union between this image and another BinaryImage
 int X()
          Returns the width (maximum X value)
 int Y()
          Returns the height (maximum Y value)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jigl.image.Image
toString
 

Field Detail

data

protected byte[][] data
Two dimensional byte array


X

protected int X
Cartesian width


Y

protected int Y
Cartesian height

Constructor Detail

BinaryImage

public BinaryImage()
Creates an empty two dimensional BinaryImage with a height and width of zero


BinaryImage

public BinaryImage(int x,
                   int y)
Creates a two dimensional BinaryImage with a width and height of x and y repectively

Parameters:
x - width of image
y - height of image

BinaryImage

public BinaryImage(int x,
                   int y,
                   byte[] data)
Creates a two dimensional BinaryImage with a width and height of x and y repectively. Image values are 1 if data[][] > 0, 0 otherwise.

Parameters:
x - width of image
y - height of image
data - one dimensional array of byte. The array is length x*y.

BinaryImage

public BinaryImage(byte[][] data)
Creates a BinaryImage from data. The size is data.length in y, and max(data.length) in x. Image values are 1 if data[][] > 0, 0 otherwise.

Parameters:
data - two dimensional array of byte.

BinaryImage

public BinaryImage(GrayImage image)
Creates a two dimensional BinaryImage from a GrayImage. Any pixel value above 0 is assigned the value 1.

Parameters:
image - GrayImage

BinaryImage

public BinaryImage(RealGrayImage image)
Creates a two dimensional BinaryImage from a RealGrayImage. Any pixel value above 0 is assigned the value 1.

Parameters:
image - RealGrayImage

BinaryImage

public BinaryImage(BinaryImage image)
Creates a two dimensional BinaryImage (shallow copy of data) from image.

Parameters:
image - BinaryImage
Method Detail

getJavaImage

public ImageProducer getJavaImage()
Gets the JavaImage from a JiglImage

Specified by:
getJavaImage in interface Image
Returns:
java.awt.image.ImageProducer
See Also:
ImageProducer

getData

public byte[][] getData()
Returns a deep copy of the image data.

Returns:
two-dimensional byte array (deep copy).

copy

public Image copy()
Makes a deep copy of this image

Specified by:
copy in interface Image
Returns:
a deep copy of BinaryImage

copy

public Image copy(ROI roi)
Makes a deep copy of this image in a Region of Interest

Specified by:
copy in interface Image
Parameters:
roi - Region of Interest of the image
Returns:
a deep copy of BinaryImage

X

public final int X()
Returns the width (maximum X value)

Specified by:
X in interface Image
Returns:
width of the image.

Y

public final int Y()
Returns the height (maximum Y value)

Specified by:
Y in interface Image
Returns:
height of image.

get

public final byte get(int x,
                      int y)
Returns the pixel value at the given x, y value

Parameters:
x - the X coordinate
y - the Y coordinate
Returns:
pixel value.

set

public final void set(int x,
                      int y,
                      int value)
Sets the pixel value at x, y to a given value

Parameters:
x - the X coordinate
y - the Y coordinate
value - the value to set the pixel to if greater than zero, it is given a value of 1, and 0 otherwise.

union

public final BinaryImage union(BinaryImage image)
Finds the union between this image and another BinaryImage

Parameters:
image - BinaryImage
Returns:
this

intersection

public final BinaryImage intersection(BinaryImage image)
Finds the intersection between this image and another BinaryImage. Return a Binary image whose pixel is on when both pixels are on in that position.

Parameters:
image - BinaryImage
Returns:
this

compliment

public final BinaryImage compliment()
Computes the complement of this image

Returns:
this

count

public final int count()
Counts the number of "on" pixels

Returns:
number of pixels of value 1.

difference

public final BinaryImage difference(BinaryImage image)
Returns the difference of this image and a BinaryImage

Parameters:
image - BinaryImage
Returns:
this

shift

public final BinaryImage shift(int horizonal,
                               int vertical)
Performs a shift on this image with out wrap.

Parameters:
horizonal - for right shift horizonal is positive for left it is negative
vertical - for down shift vertical is positive for up it is negative
Returns:
this

JIGL
v1.6

Submit a bug or feature
Revised in May 2002 by Weiming Liu