cbr.ccv
Class Span

java.lang.Object
  extended bycbr.ccv.Span

public class Span
extends Object

This class manges a span of a scanline. It supports testing for intersection and ordering of spans, as well as joining the pixel areas of spans. Hence, this class also acts as a pixel area consisting of accumulated spans. A span is a continuous segment of a scanline consisting of pixels of the same color.

Version:
"$Id: Span.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Volker Roth

Field Summary
protected  Area area_
          The area of this span.
protected  int color_
          The color of the span.
protected  int left_
          The index of the leftmost pixel in the span.
protected  int length_
          The length of the span in pixels.
 
Constructor Summary
Span(int length)
          Creates a fake span with the given length but size and color zero.
Span(int left, int length, int color)
          Creates an instance with the given start index, length and color.
 
Method Summary
 boolean endsRightOf(Span span)
          Returns true iff a pixel of this span is to the right of the rightmost pixel of the given span.
 int init(byte[] px, int off, int left, int max)
          Initialises a span from the given pixel array.
 void init(int left, int length, int color)
          This method reinitialises a span with the given parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

area_

protected Area area_
The area of this span.


left_

protected int left_
The index of the leftmost pixel in the span.


length_

protected int length_
The length of the span in pixels.


color_

protected int color_
The color of the span.

Constructor Detail

Span

public Span(int left,
            int length,
            int color)
Creates an instance with the given start index, length and color. Initially, the span has no area associated with it.

Parameters:
left - The index of the leftmost pixel of the span, starting at 0.
length - The length of the span in pixels.
color - The color of the span's pixels.

Span

public Span(int length)
Creates a fake span with the given length but size and color zero.

Parameters:
length - The length of the span.
Method Detail

init

public void init(int left,
                 int length,
                 int color)
This method reinitialises a span with the given parameters. The area of this span is cleared.

Parameters:
left - The index of the leftmost pixel of the span, starting at 0.
length - The length of the span in pixels.
color - The color of the span's pixels.

init

public int init(byte[] px,
                int off,
                int left,
                int max)
Initialises a span from the given pixel array. The span starts at the given left index and searches the pixel array starting from the given offset to the right for equal pixel values up to the given maximum. The results are used to initialise this span. Beware that the sum of max and off does not exceed the length of the pixel array.

The area of this span is cleared upon calling this method.

Parameters:
px - The array of pixel values. Each byte represents a pixel.
off - The offset into the pixel array from which the initialisation starts.
left - The leftmost pixel index of the span.
max - The maximum length of the span.
Returns:
The length of the initialised span.

endsRightOf

public boolean endsRightOf(Span span)
Returns true iff a pixel of this span is to the right of the rightmost pixel of the given span.

Returns:
true if this span extends beyond the right part of the given span.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.