net.sourceforge.javaocr.ocr
Class AbstractLinearImage

java.lang.Object
  extended by net.sourceforge.javaocr.ocr.AbstractLinearImage
All Implemented Interfaces:
Image
Direct Known Subclasses:
ByteImage, PixelImage

public abstract class AbstractLinearImage
extends Object
implements Image

abstract base class encapsulating image functionality for images represented by linear arrays. This class is stateful in regard to filtering, and thus not thread safe. Those optimisations aim to reduce method invocations to be performant on davlik (android) where direct field access if more performant than going through getter

Author:
Konstantin Pribluda

Field Summary
protected  int arrayHeight
          Height of the image, in pixels.
protected  int arrayWidth
          Width of the image, in pixels.
protected  float aspectRatio
          Aspect ratio of the image (width/height).
(package private)  int border
           
protected  int currentIndex
          actual position being processed
protected  int height
          actual image height
protected  int originX
          X-origin inside array
protected  int originY
          Y-origin inside array
(package private)  int step
           
protected  int width
          actual image width
 
Constructor Summary
protected AbstractLinearImage(int arrayWidth, int arrayHeight)
          construct image over while linear array with specified arrayWidth and arrayHeight
protected AbstractLinearImage(int arrayWidth, int arrayHeight, int originX, int originY, int width, int height)
          construct image over subset of image in linear array
 
Method Summary
 Image column(int x)
          full column out of image
 void copy(Image dst)
          copy image content to destination.
 void flip(Image dst)
          copy image content to destination with coordinate flip.
abstract  int get()
          retrieve current pixel empty
 int get(int x, int y)
          Get the empty of a pixel at a specific x,y position.
 int getArrayHeight()
           
 int getArrayWidth()
           
 float getAspectRatio()
          aspect ration of this image TODO: do we actually need this?
 int getHeight()
           
 int getOriginX()
           
 int getOriginY()
           
 int getWidth()
           
 boolean hasNext()
          whether next pixel is available
 boolean horizontalSpanEquals(int y, int from, int to, int value)
          whether given span equals to specific empty
 void iterateH(int y)
          convenience method to initialize iterator over whole image row
 void iterateH(int y, int from, int to)
          initialize iterator over part of row
 void iterateV(int x)
          convenience method to initialize iterator over whole image column
 void iterateV(int x, int from, int to)
          initialize iterator over part of column
 int next()
          advance and retrieve next available pixel
 void next(int pixel)
          advance to next and store pixel at current position
abstract  void put(int value)
          save pixel to current position
 void put(int x, int y, int value)
          store pixel empty.
 Image row(int y)
          full row out of image
protected  void setCurrentIndex(int x, int y)
           
 String toString()
           
 boolean verticalSpanEquals(int x, int from, int to, int value)
          whether vertical line is empty between specified points
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sourceforge.javaocr.Image
chisel
 

Field Detail

arrayWidth

protected final int arrayWidth
Width of the image, in pixels.


arrayHeight

protected final int arrayHeight
Height of the image, in pixels.


originX

protected final int originX
X-origin inside array


originY

protected final int originY
Y-origin inside array


width

protected final int width
actual image width


height

protected final int height
actual image height


currentIndex

protected int currentIndex
actual position being processed


aspectRatio

protected final float aspectRatio
Aspect ratio of the image (width/height).


step

int step

border

int border
Constructor Detail

AbstractLinearImage

protected AbstractLinearImage(int arrayWidth,
                              int arrayHeight)
construct image over while linear array with specified arrayWidth and arrayHeight

Parameters:
arrayWidth - image arrayWidth
arrayHeight - image arrayHeight

AbstractLinearImage

protected AbstractLinearImage(int arrayWidth,
                              int arrayHeight,
                              int originX,
                              int originY,
                              int width,
                              int height)
construct image over subset of image in linear array

Parameters:
arrayWidth - full image arrayWidth
arrayHeight - full image arrayHeight
originX - X-origin of subimage
originY - Y-origin of subimage
width - subimage arrayWidth
height - subimage arrayHeight
Method Detail

get

public abstract int get()
retrieve current pixel empty

Specified by:
get in interface Image
Returns:
current pixel empty

put

public abstract void put(int value)
save pixel to current position

Specified by:
put in interface Image
Parameters:
value -

get

public int get(int x,
               int y)
Get the empty of a pixel at a specific x,y position.

Specified by:
get in interface Image
Parameters:
x - The pixel's x position.
y - The pixel's y position.
Returns:
The empty of the pixel.

setCurrentIndex

protected void setCurrentIndex(int x,
                               int y)

put

public void put(int x,
                int y,
                int value)
store pixel empty. manipulates current image pointer ( do not call it while iterating, use put(pixel) instead)

Specified by:
put in interface Image
Parameters:
x -
y -
value -

getArrayHeight

public int getArrayHeight()

getArrayWidth

public int getArrayWidth()

getAspectRatio

public float getAspectRatio()
Description copied from interface: Image
aspect ration of this image TODO: do we actually need this?

Specified by:
getAspectRatio in interface Image
Returns:

getHeight

public int getHeight()
Specified by:
getHeight in interface Image
Returns:
image height

getWidth

public int getWidth()
Specified by:
getWidth in interface Image
Returns:
image width

getOriginX

public int getOriginX()
Specified by:
getOriginX in interface Image
Returns:
origin inside bigger image. 0 if this is not subimage

getOriginY

public int getOriginY()
Specified by:
getOriginY in interface Image

horizontalSpanEquals

public boolean horizontalSpanEquals(int y,
                                    int from,
                                    int to,
                                    int value)
whether given span equals to specific empty

Specified by:
horizontalSpanEquals in interface Image
Parameters:
y - Y empty
from - inclusive from
to - inclusive to
value - empty to be mathced
Returns:

verticalSpanEquals

public boolean verticalSpanEquals(int x,
                                  int from,
                                  int to,
                                  int value)
Description copied from interface: Image
whether vertical line is empty between specified points

Specified by:
verticalSpanEquals in interface Image
Parameters:
x - X Value
from - inclusive from
to - inclusive to
value - valye to be matched
Returns:

iterateV

public void iterateV(int x,
                     int from,
                     int to)
Description copied from interface: Image
initialize iterator over part of column

Specified by:
iterateV in interface Image

iterateH

public void iterateH(int y,
                     int from,
                     int to)
Description copied from interface: Image
initialize iterator over part of row

Specified by:
iterateH in interface Image
from - from position
to - to position

iterateH

public void iterateH(int y)
Description copied from interface: Image
convenience method to initialize iterator over whole image row

Specified by:
iterateH in interface Image

iterateV

public void iterateV(int x)
Description copied from interface: Image
convenience method to initialize iterator over whole image column

Specified by:
iterateV in interface Image

hasNext

public boolean hasNext()
Description copied from interface: Image
whether next pixel is available

Specified by:
hasNext in interface Image
Returns:

next

public int next()
Description copied from interface: Image
advance and retrieve next available pixel

Specified by:
next in interface Image
Returns:

next

public void next(int pixel)
advance to next and store pixel at current position

Specified by:
next in interface Image
Parameters:
pixel -

copy

public void copy(Image dst)
copy image content to destination. we hope that dimensions match

Specified by:
copy in interface Image
Parameters:
dst -

flip

public void flip(Image dst)
copy image content to destination with coordinate flip. we hope that dimensions match

Specified by:
flip in interface Image
Parameters:
dst -

toString

public String toString()
Overrides:
toString in class Object

row

public Image row(int y)
Description copied from interface: Image
full row out of image

Specified by:
row in interface Image
Parameters:
y - coordinate
Returns:
row image

column

public Image column(int x)
Description copied from interface: Image
full column out of image

Specified by:
column in interface Image
Parameters:
x - coordinate
Returns:
column image


Copyright © -2012. All Rights Reserved.