br.usp.ime.klava.segmentit.structures
Class Pixel

java.lang.Object
  extended by br.usp.ime.klava.segmentit.structures.Pixel
All Implemented Interfaces:
java.lang.Comparable<Pixel>

public class Pixel
extends java.lang.Object
implements java.lang.Comparable<Pixel>

The smallest atomic unit in images.

Author:
Bruno Klava

Field Summary
static int MASK
          Used for masking the markers pixels that have to be labeled (by a connected color component labeling function).
 
Constructor Summary
Pixel(int grayLevel, int x, int y)
          Creates a pixel with the given grayLevel localized at (x,y).
 
Method Summary
 int compareTo(Pixel otherPixel)
          Compares this pixel to otherPixel by their gray levels.
 boolean costGreaterThan(Cost cost)
          Returns if the cost of this Pixel is greater than the given cost.
 Cost costPathToNeighbor(Pixel neighbor)
          Returns the cost of the path given the current path to this Pixel extending it to neighbor.
 Cost getCost()
          Returns the cost of this Pixel.
 java.lang.String getCostString()
          Returns a String representation of the cost of this Pixel.
 int getGrayLevel()
          Returns the gray level of this Pixel.
 int getLabel()
          Return the label of this Pixel.
 Pixel getPredecessor()
          Returns the predecessor of this Pixel in a path from a marker pixel.
 int getX()
          Returns the x-coordinate of this Pixel.
 int getY()
          Returns the y-coordinate of this Pixel.
 boolean isMarker()
          Returns if this Pixel is a marker.
 boolean isWatershed()
          Returns if this Pixel belongs to the watershed lines.
 void reset(boolean marker)
          Resets the fields of this Pixel.
 void setCost(Cost cost)
          Sets the cost of this Pixel to cost.
 void setCost(int max, int dist)
          Sets the cost of this Pixel to (max, dist).
 void setLabel(int label)
          Sets the label of this Pixel.
 void setMarker(boolean marker)
          Sets the value of marker.
 void setPredecessor(Pixel predecessor)
          Sets the predecessor of this Pixel in a path from a marker pixel.
 void setWatershed(boolean watershed)
          Sets if this Pixel belongs to the watershed lines.
 java.lang.String toString()
          Returns a String representation of this Pixel.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MASK

public static final int MASK
Used for masking the markers pixels that have to be labeled (by a connected color component labeling function).

See Also:
Constant Field Values
Constructor Detail

Pixel

public Pixel(int grayLevel,
             int x,
             int y)
Creates a pixel with the given grayLevel localized at (x,y).

Parameters:
grayLevel - the gray level of this Pixel
x - the x-coordinate of this Pixel
y - the y-coordinate of this Pixel
Method Detail

isWatershed

public boolean isWatershed()
Returns if this Pixel belongs to the watershed lines.

Returns:
true if this Pixel belongs to the watershed lines

setWatershed

public void setWatershed(boolean watershed)
Sets if this Pixel belongs to the watershed lines.

Parameters:
watershed - the value to be set to the watershed property

getGrayLevel

public int getGrayLevel()
Returns the gray level of this Pixel.

Returns:
the gray level of this Pixel

getCost

public Cost getCost()
Returns the cost of this Pixel.

Returns:
the cost of this Pixel

setCost

public void setCost(Cost cost)
Sets the cost of this Pixel to cost.

Parameters:
cost - the cost of this Pixel

setCost

public void setCost(int max,
                    int dist)
Sets the cost of this Pixel to (max, dist).

Parameters:
max - the first component of the cost
dist - the second component of the cost

getLabel

public int getLabel()
Return the label of this Pixel.

Returns:
the label of this Pixel

setLabel

public void setLabel(int label)
Sets the label of this Pixel.

Parameters:
label - the label of this Pixel

getX

public int getX()
Returns the x-coordinate of this Pixel.

Returns:
the x-coordinate of this Pixel

getY

public int getY()
Returns the y-coordinate of this Pixel.

Returns:
the y-coordinate of this Pixel

getPredecessor

public Pixel getPredecessor()
Returns the predecessor of this Pixel in a path from a marker pixel.

Returns:
the predecessor of this Pixel

setPredecessor

public void setPredecessor(Pixel predecessor)
Sets the predecessor of this Pixel in a path from a marker pixel.

Parameters:
predecessor - the predecessor of this Pixel

isMarker

public boolean isMarker()
Returns if this Pixel is a marker.

Returns:
true if this Pixel is a marker

setMarker

public void setMarker(boolean marker)
Sets the value of marker.

Parameters:
marker - if this Pixel is a marker

reset

public void reset(boolean marker)
Resets the fields of this Pixel. Sets:

Parameters:
marker - if this is a marker Pixel

costGreaterThan

public boolean costGreaterThan(Cost cost)
Returns if the cost of this Pixel is greater than the given cost.

Parameters:
cost - the cost to be compared
Returns:
true if the cost of this Pixel is greater than the given cost

getCostString

public java.lang.String getCostString()
Returns a String representation of the cost of this Pixel.


costPathToNeighbor

public Cost costPathToNeighbor(Pixel neighbor)
Returns the cost of the path given the current path to this Pixel extending it to neighbor.

Parameters:
neighbor - a neighbor of this Pixel
Returns:
the cost of the path from a marker to this Pixel extended to neighbor

toString

public java.lang.String toString()
Returns a String representation of this Pixel.

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(Pixel otherPixel)
Compares this pixel to otherPixel by their gray levels.

Specified by:
compareTo in interface java.lang.Comparable<Pixel>