JIGL
v1.6

jigl.signal
Class BinarySignal

java.lang.Object
  |
  +--jigl.signal.BinarySignal
All Implemented Interfaces:
Signal

public class BinarySignal
extends Object
implements Signal

BinarySignal is a 1-d array of byte. All the values in a BinarySignal are always either 1 or 0.


Field Summary
protected  byte[] data
          One dimensional byte array
protected  int length
          Cartesian width
 
Constructor Summary
BinarySignal()
          Creates an empty one dimensional BinarySignal with a length of zero
BinarySignal(BinarySignal img)
          Creates a one dimensional BinarySignal (shallow copy) from BinarySignal img
BinarySignal(DiscreteSignal img)
          Creates a one dimensional BinarySignal from a DiscreteSignal.
BinarySignal(int x)
          Creates a one dimensional BinarySignal with a length of x
BinarySignal(int x, byte[] dat)
          Creates a one dimensional BinarySignal with a length of x from array dat.
BinarySignal(RealSignal img)
          Creates a one dimensional BinarySignal from a RealSignal.
 
Method Summary
 BinarySignal compliment()
          Returns the complement signal of this signal
 Signal copy()
          Makes a deep copy of this Signal
 int count()
          Counts the number of "on" pixels
 BinarySignal difference(BinarySignal signal)
          Returns the difference of this signal and a BinarySignal
 byte get(int x)
          Returns the pixel value at the given x value
 BinarySignal intersection(BinarySignal signal)
          Finds the intersection between this image and another BinarySignal
 int length()
          Returns the width (maximum length value)
 void set(int x, int value)
          Sets the pixel value at x to a given value
 BinarySignal shift(int horizontal)
          Performs a shift on this image.
 BinarySignal union(BinarySignal signal)
          Finds the union between this signal and another BinarySignal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jigl.signal.Signal
toString
 

Field Detail

data

protected byte[] data
One dimensional byte array


length

protected int length
Cartesian width

Constructor Detail

BinarySignal

public BinarySignal()
Creates an empty one dimensional BinarySignal with a length of zero


BinarySignal

public BinarySignal(int x)
Creates a one dimensional BinarySignal with a length of x


BinarySignal

public BinarySignal(int x,
                    byte[] dat)
Creates a one dimensional BinarySignal with a length of x from array dat. If dat[k]>0,the value of the signal is set as 1. Otherwise the value is set to 0.

Parameters:
x - width of image
dat - one dimensional array of short. The array is length x.

BinarySignal

public BinarySignal(DiscreteSignal img)
Creates a one dimensional BinarySignal from a DiscreteSignal. It converts a DiscreteSignal to a BinarySignal.


BinarySignal

public BinarySignal(RealSignal img)
Creates a one dimensional BinarySignal from a RealSignal. It converts a RealSignal to a BinarySignal.


BinarySignal

public BinarySignal(BinarySignal img)
Creates a one dimensional BinarySignal (shallow copy) from BinarySignal img

Method Detail

copy

public Signal copy()
Makes a deep copy of this Signal

Specified by:
copy in interface Signal
Returns:
a deep copy of BinarySignal

length

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

Specified by:
length in interface Signal

get

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

Parameters:
x - the length coordinate

set

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

Parameters:
x - the length coordinate
value - the value to set the pixel to

union

public final BinarySignal union(BinarySignal signal)
Finds the union between this signal and another BinarySignal

Returns:
this

intersection

public final BinarySignal intersection(BinarySignal signal)
Finds the intersection between this image and another BinarySignal

Returns:
this

compliment

public final BinarySignal compliment()
Returns the complement signal of this signal


count

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


difference

public final BinarySignal difference(BinarySignal signal)
Returns the difference of this signal and a BinarySignal

Returns:
this

shift

public final BinarySignal shift(int horizontal)
Performs a shift on this image. The new part of the signal is set to 0.

Parameters:
horizontal - for right shift if horizontal is positive and for left if it is negative
Returns:
this

JIGL
v1.6

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