Class Boundary

java.lang.Object
  extended by Boundary

public class Boundary
extends java.lang.Object

Class Boundary performs boundary operations and its instance exists in the ImageData object.

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The Flicker Mozilla and Legal files are available on http://open2dprot.sourceforge.net/Flicker

Version:
$Date$ $Revision$
Author:
P. Lemkin (LECB/NCI), G. Thornwall (SAIC), Frederick, MD
See Also:
Flicker Home

Field Summary
(package private)  int area
           
 java.awt.Point[] bnd
          Boundary of object
(package private)  java.awt.Color bndColor
          color to draw boundary
 boolean bndOpenFlag
          boundary is active
(package private)  double density
           
(package private)  double densRaw
           
private  Flicker flk
           
(package private)  int iHeight
          height of image to measure
(package private)  int iWidth
          width of image to measure
(package private)  float[] mapGrayToOD
          gray scale to OD map
 int MAX_BND
          Max boundary size
(package private)  int maxBnd
          Max size of boundary array
(package private)  double maxd
           
 java.lang.String measType
          "Quant" or "Bkgrd"
(package private)  int measurementNbr
          measurement #
(package private)  int merx1
           
(package private)  int merx2
           
(package private)  int mery1
           
(package private)  int mery2
           
(package private)  double mind
           
(package private)  double mnbackground
           
(package private)  int nPoints
          # points drawn so far
(package private)  int perim
           
(package private)  double sdDensity
           
(package private)  double sx
           
(package private)  double sxy
           
(package private)  double sy
           
(package private)  boolean validFeaturesFlag
          Set object features as function of input pixels [] and boundary
(package private)  double xAbs
           
(package private)  int[] xPoints
          coordinates for drawing using polyline
(package private)  double yAbs
           
(package private)  int[] yPoints
          coordinates for drawing using polyline
 
Constructor Summary
Boundary(Flicker flk)
          Boundary() - constructor.
 
Method Summary
 void clean()
          clean() - clean up before init or when kill instance before GC
 java.lang.String cvFeatures2str(java.lang.String imageFile)
          cvFeatures2str() - cvt object features to printable string
 void drawBoundary(java.awt.Graphics g)
          drawBoundary() - draw boundary backwards
 void drawBoundaryInImage(java.awt.Graphics g)
          drawBoundaryInImage() - redraw boundary in window if visible.
 void eraseBoundary()
          eraseBoundary() - erase boundary backwards one at a time.
 boolean finishMeasurement(int iWidth, int iHeight, int[] inputPix, int pixelMask)
          finishMeasurement() - finish measurement and compute features
 java.awt.Point[] getBoundary()
          getBoundary() - return boundary
 int getBoundaryLength()
          getBoundaryLength() - return nPoints for boundary
 boolean getValidFeaturesFlag()
          getValidFeaturesFlag() - get the valid features set after measurement
 int interpolatePoints(int xOld, int yOld, int xNew, int yNew)
          interpolatePoints() - interpolate (xOld,yOld) to (xNew,yNew) into list of x,y coordinates of maximum size maxN which are pushed onto the bnd[] point list.
 void measureRegion(int[] inputPixels, int pixelMask)
          measureRegion() - compute image features for object inside boundary.
 void processBoundaryMode(int x, int y, boolean shiftMod)
          processBoundaryMode() - process drawing mouse event if boundaryMode
 int pushBoundary(int x, int y)
          pushBoundary() - push unique boundary points from last point to current
 void regrowBoundary(int newSize)
          regrowBoundary() - increase boundary size
 void setBndColor(java.awt.Color c)
          setBndColor() - set the boundary drawing color
 void setBndState(boolean bndOpenFlag)
          setBndState() - set the boundary state in the imageCanvas
 void setMapGrayToOD(float[] mapGrayToOD)
          setMapGrayToOD() - set the MapGrayToOD[] table
 void startMeasurement(java.lang.String measType, int iWidth, int iHeight)
          startMeasurement() - start measurement of object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flk

private Flicker flk

MAX_BND

public final int MAX_BND
Max boundary size

See Also:
Constant Field Values

measType

public java.lang.String measType
"Quant" or "Bkgrd"


bndOpenFlag

public boolean bndOpenFlag
boundary is active


mapGrayToOD

float[] mapGrayToOD
gray scale to OD map


bnd

public java.awt.Point[] bnd
Boundary of object


iWidth

int iWidth
width of image to measure


iHeight

int iHeight
height of image to measure


measurementNbr

int measurementNbr
measurement #


maxBnd

int maxBnd
Max size of boundary array


nPoints

int nPoints
# points drawn so far


bndColor

java.awt.Color bndColor
color to draw boundary


validFeaturesFlag

boolean validFeaturesFlag
Set object features as function of input pixels [] and boundary


mnbackground

double mnbackground

density

double density

sx

double sx

sy

double sy

sxy

double sxy

maxd

double maxd

mind

double mind

xAbs

double xAbs

yAbs

double yAbs

densRaw

double densRaw

sdDensity

double sdDensity

area

int area

perim

int perim

merx1

int merx1

merx2

int merx2

mery1

int mery1

mery2

int mery2

xPoints

int[] xPoints
coordinates for drawing using polyline


yPoints

int[] yPoints
coordinates for drawing using polyline

Constructor Detail

Boundary

public Boundary(Flicker flk)
Boundary() - constructor.

Method Detail

setMapGrayToOD

public void setMapGrayToOD(float[] mapGrayToOD)
setMapGrayToOD() - set the MapGrayToOD[] table

Parameters:
mapGrayToOD - map of grayscale to OD

drawBoundary

public void drawBoundary(java.awt.Graphics g)
drawBoundary() - draw boundary backwards

Parameters:
g - is graphics context where we draw the boundary

clean

public void clean()
clean() - clean up before init or when kill instance before GC


setBndState

public final void setBndState(boolean bndOpenFlag)
setBndState() - set the boundary state in the imageCanvas

Parameters:
bndOpenFlag - to toggle boundary drawing overlay

setBndColor

public final void setBndColor(java.awt.Color c)
setBndColor() - set the boundary drawing color

Parameters:
c - is boundary color

getValidFeaturesFlag

public final boolean getValidFeaturesFlag()
getValidFeaturesFlag() - get the valid features set after measurement

Returns:
true if features are valid (i.e. boundary defined and features computed)

startMeasurement

public final void startMeasurement(java.lang.String measType,
                                   int iWidth,
                                   int iHeight)
startMeasurement() - start measurement of object.

Parameters:
measType - is "Quant" or "Bkgrd"
iWidth - is width of image
iHeight - is height of image
See Also:
finishMeasurement(int, int, int[], int)

measureRegion

public void measureRegion(int[] inputPixels,
                          int pixelMask)
measureRegion() - compute image features for object inside boundary. Measure features (area, perimeter, centroid, and integrated density, if the PPX grayToNDmap[] is calibrated.
 ALGORITHM:
 [1] Given contiguous the convex hull list of points enclosing region.
 [2] Define the region by a run length map with one run/line.
 [3] When finished measuring, compute features as function of pixel
     data inside of the RLM. (Only count pixels INSIDE of boundary.)
 [4] Then conditionally print these out with the area, density, etc.

 This algorithm is the same used in the FLICKER program described
 in:
   Lemkin,P., Merril,C., Lipkin,L., etal. "Software Aids for
   the Analysis of 2D Gel Electrophoresis Images", Comp. Biomed.
   Res. 12, 517 (1979).

Parameters:
inputPixels - is array of pixels to use.
pixelMask - is pixel mask to use on inputPixels

regrowBoundary

public final void regrowBoundary(int newSize)
regrowBoundary() - increase boundary size

Parameters:
newSize - of boundary

interpolatePoints

public final int interpolatePoints(int xOld,
                                   int yOld,
                                   int xNew,
                                   int yNew)
interpolatePoints() - interpolate (xOld,yOld) to (xNew,yNew) into list of x,y coordinates of maximum size maxN which are pushed onto the bnd[] point list. Algorithm taken from Lemkin etal, Comput. in Biomed. Res., 12, 517-544 (1979). Compute the interpolated line from (xOld,yOld) to (xNew,yNew) storing it in the arrays and returning the number of points generated.

Parameters:
xOld - is starting coordinate
yOld - is starting coordinate
xNew - is final coordinate
yNew - is final coordinate
Returns:
the # of points generated this trip.

getBoundaryLength

public final int getBoundaryLength()
getBoundaryLength() - return nPoints for boundary

Returns:
length of boundary

getBoundary

public final java.awt.Point[] getBoundary()
getBoundary() - return boundary

Returns:
boundary points

pushBoundary

public final int pushBoundary(int x,
                              int y)
pushBoundary() - push unique boundary points from last point to current

Parameters:
x - is new boundary coordinate
y - is new boundary coordinate
Returns:
length of boundary or 0 if there is a problem

eraseBoundary

public final void eraseBoundary()
eraseBoundary() - erase boundary backwards one at a time.


finishMeasurement

public boolean finishMeasurement(int iWidth,
                                 int iHeight,
                                 int[] inputPix,
                                 int pixelMask)
finishMeasurement() - finish measurement and compute features

Parameters:
iWidth - is getSize().width of image
iHeight - is getSize().height of image
inputPix - is image buffer pixels from iData{1|2}. input pixels
pixelMask - to get gray value from low order inputPix bits
Returns:
true if ok.

cvFeatures2str

public java.lang.String cvFeatures2str(java.lang.String imageFile)
cvFeatures2str() - cvt object features to printable string

Parameters:
imageFile - is image file
Returns:
printable string

drawBoundaryInImage

public final void drawBoundaryInImage(java.awt.Graphics g)
drawBoundaryInImage() - redraw boundary in window if visible. If the boundary exists, then draw bnd[0:nPoints-1] in bndColor.

Parameters:
g - is graphics context

processBoundaryMode

public final void processBoundaryMode(int x,
                                      int y,
                                      boolean shiftMod)
processBoundaryMode() - process drawing mouse event if boundaryMode

Parameters:
x - is point to push
y - is point to push
shiftMod - status