Class ImageDataMeas

java.lang.Object
  extended by ImageDataMeas

public class ImageDataMeas
extends java.lang.Object

ImageDataMeas class supports image data spot measurement object access.

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
 float bkgrdGrayValue
          Capture "background" pixel gray or OD value.
 int bkgrdObjX
          Capture "background" X coordinate
 int bkgrdObjY
          Capture "background" Y coordinate
 Spot curSpot
          Current spot set with showMeasValue if being measured.
static Flicker flk
          Flicker global classes
 ImageData id
          Instance of ImageData for extended classes
static int[] maskArea
          List of areas under each mask index by the mask radius
static int[][][] maskNxN
          Array of masks [0:nMasks-1][0:Nr][0:Nr] where Nr is (2*radius+1)
static int[] maskRadius
          Array of mask radius size where Nr is (2*radius+1)
static int[] maskTotWeight
          List of total weights under each mask index by the mask radius
 float maxBkgrdGrayValue
          Capture max "background" pixel gray or OD value
 float maxGrayValue
          Capture max pixel gray or OD value within mask
 float maxMeasGrayValue
          Capture max "measurement" pixel gray or OD value
 float meanBkgrdGrayValue
          Capture mean "background" pixel gray or OD value.
 float meanGrayValue
          Capture mean pixel gray or OD value within mask
 float meanMeasGrayValue
          Capture mean "measurement" pixel gray or OD value.
 float measGrayValue
          Capture "measurement" pixel gray or OD value.
 int measObjX
          Capture "background" X coordinate
 int measObjY
          Capture "background" Y coordinate
 float minBkgrdGrayValue
          Capture min "background" pixel gray or OD value
 float minGrayValue
          Capture min pixel gray or OD value within mask
 float minMeasGrayValue
          Capture min "measurement" pixel gray or OD value
static int nMasks
          number of masks [0:nMasks-1][0:Nr][0:Nr]
 float totGrayValue
          Capture total pixel gray or OD value within mask
 float totMeasGrayValue
          Capture total "measurement" pixel gray or OD value.
static Util util
          extended Flicker state variable class
 
Constructor Summary
ImageDataMeas()
          ImageData() - Constructor for creating spot masks Defaults to Flicker.MAX_CIRCLE_RADIUS # of masks
ImageDataMeas(ImageData iData)
          ImageData() - Constructor for spot measurement extension
ImageDataMeas(int maxRadiusToCreate)
          ImageData() - Constructor for creating spot masks of size 1x1 to (maxRadiusToCreate X maxRadiusToCreate)
 
Method Summary
 boolean calcHistogram(int x1, int y1, int x2, int y2)
          calcHistogram() - compute grayscale histogram under the specified computing window [x1:x2, y1:y2].
private static int calcMaskArea(int[][] mask)
          calcMaskArea() - compute the area under the mask
private static int calcMaskTotWeight(int[][] mask)
          calcMaskTotWeight() - compute the total weights under the mask
 float calcSumValuesUnderMask(int radius, int x0, int y0, boolean useTotDensityFlag)
          calcSumValuesUnderMask() - compute sum of pixel values under the mask corresponding to the mask set by the current radius.
 float captureBackgroundValue()
          captureBackgroundValue() - capture the values under the mask of the selected image if it is left or right and assign it to the background pixel value for the current image.
 float captureMeasCWvalue()
          captureMeasCWvalue() - capture the pixel values under the computing window of the selected image if it is left or right and assign it to the measurement pixel value for the current image.
 float captureMeasValue()
          captureMeasValue() - capture the pixel values under the mask of the selected image if it is left or right and assign it to the measurement pixel value for the current image.
 void clean()
          clean() - init the image data measurement state
static int createMaskDatabase(int maxCircleRadius)
          createMaskDatabase() - create the set of circular masks of size NrxNr stored in a 3D array [0:nMasks-1][0:Nr][0:Nr] where Nr is (2*radius+1)
static java.lang.String cvMaskToStr(int[][] mask, java.lang.String msg)
          cvMaskToStr() - convert a mask to a printable string
 java.lang.String cvtGrayValueToODstr(int g)
          cvtGrayValueToODstr() - convert gray value to OD string if the map has been defined for the ImageData instance
 int getPixelValue(int x, int y)
          getPixelValue() - get the pixel value for the image at (x,y).
 java.lang.String getPixelValueStr(int xObj, int yObj)
          getPixelValueStr() - get the pixel value string for the image where the trial object (xObj,yObj) is located.
static void main(java.lang.String[] args)
          main() - createMaskDatabase function for debugging...
static void setCircleMaskRadius(int radius, ImageData iData)
          setCircleMaskRadius() - set the circle radius for measurement and background, as well as the circle mask given the radius.
 void setupCircularMaskStatistics()
          setupCircularMaskStatistics()- compute the mask area and total weights for each mask.
 java.lang.String showBkgrdValue()
          showBkgrdValue() - print the background measurement value.
 java.lang.String showMeasValue(java.lang.String measMode)
          showMeasValue() - print the measurement value subtracting the background value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flk

public static Flicker flk
Flicker global classes


util

public static Util util
extended Flicker state variable class


id

public ImageData id
Instance of ImageData for extended classes


maskNxN

public static int[][][] maskNxN
Array of masks [0:nMasks-1][0:Nr][0:Nr] where Nr is (2*radius+1)


nMasks

public static int nMasks
number of masks [0:nMasks-1][0:Nr][0:Nr]


maskRadius

public static int[] maskRadius
Array of mask radius size where Nr is (2*radius+1)


maskArea

public static int[] maskArea
List of areas under each mask index by the mask radius


maskTotWeight

public static int[] maskTotWeight
List of total weights under each mask index by the mask radius


maxGrayValue

public float maxGrayValue
Capture max pixel gray or OD value within mask


minGrayValue

public float minGrayValue
Capture min pixel gray or OD value within mask


curSpot

public Spot curSpot
Current spot set with showMeasValue if being measured.


totGrayValue

public float totGrayValue
Capture total pixel gray or OD value within mask


meanGrayValue

public float meanGrayValue
Capture mean pixel gray or OD value within mask


meanBkgrdGrayValue

public float meanBkgrdGrayValue
Capture mean "background" pixel gray or OD value.


meanMeasGrayValue

public float meanMeasGrayValue
Capture mean "measurement" pixel gray or OD value.


totMeasGrayValue

public float totMeasGrayValue
Capture total "measurement" pixel gray or OD value.


bkgrdGrayValue

public float bkgrdGrayValue
Capture "background" pixel gray or OD value. This is either mean or tottal integrated (sum over mask area) density.


measGrayValue

public float measGrayValue
Capture "measurement" pixel gray or OD value. This is either mean or tottal integrated (sum over mask area) density.


maxBkgrdGrayValue

public float maxBkgrdGrayValue
Capture max "background" pixel gray or OD value


maxMeasGrayValue

public float maxMeasGrayValue
Capture max "measurement" pixel gray or OD value


minBkgrdGrayValue

public float minBkgrdGrayValue
Capture min "background" pixel gray or OD value


minMeasGrayValue

public float minMeasGrayValue
Capture min "measurement" pixel gray or OD value


bkgrdObjX

public int bkgrdObjX
Capture "background" X coordinate


bkgrdObjY

public int bkgrdObjY
Capture "background" Y coordinate


measObjX

public int measObjX
Capture "background" X coordinate


measObjY

public int measObjY
Capture "background" Y coordinate

Constructor Detail

ImageDataMeas

public ImageDataMeas(ImageData iData)
ImageData() - Constructor for spot measurement extension

Parameters:
iData - is the ImageData instance

ImageDataMeas

public ImageDataMeas()
ImageData() - Constructor for creating spot masks Defaults to Flicker.MAX_CIRCLE_RADIUS # of masks


ImageDataMeas

public ImageDataMeas(int maxRadiusToCreate)
ImageData() - Constructor for creating spot masks of size 1x1 to (maxRadiusToCreate X maxRadiusToCreate)

Parameters:
maxRadiusToCreate -
Method Detail

clean

public void clean()
clean() - init the image data measurement state


createMaskDatabase

public static int createMaskDatabase(int maxCircleRadius)
createMaskDatabase() - create the set of circular masks of size NrxNr stored in a 3D array [0:nMasks-1][0:Nr][0:Nr] where Nr is (2*radius+1)

Parameters:
maxCircleRadius - is the maximum circle size radius
Returns:
the # of masks generated.

cvMaskToStr

public static java.lang.String cvMaskToStr(int[][] mask,
                                           java.lang.String msg)
cvMaskToStr() - convert a mask to a printable string

Parameters:
mask - is [nR][nR] to print
msg - is optional message to prefix out if not null
Returns:
string representing the matrix

setupCircularMaskStatistics

public void setupCircularMaskStatistics()
setupCircularMaskStatistics()- compute the mask area and total weights for each mask. Also set the current mask


calcMaskArea

private static int calcMaskArea(int[][] mask)
calcMaskArea() - compute the area under the mask

Parameters:
mask - is 2D mask
Returns:
total non-zero area under the mask

calcMaskTotWeight

private static int calcMaskTotWeight(int[][] mask)
calcMaskTotWeight() - compute the total weights under the mask

Parameters:
mask - is 2D mask
Returns:
total non-zero total weights under the mask

setCircleMaskRadius

public static void setCircleMaskRadius(int radius,
                                       ImageData iData)
setCircleMaskRadius() - set the circle radius for measurement and background, as well as the circle mask given the radius.

Parameters:
radius - - of the circle mask
iData - - if set to I1 or I2, null otherwise

calcSumValuesUnderMask

public float calcSumValuesUnderMask(int radius,
                                    int x0,
                                    int y0,
                                    boolean useTotDensityFlag)
calcSumValuesUnderMask() - compute sum of pixel values under the mask corresponding to the mask set by the current radius. If the gray to OD map exists, then map it and return integrated OD. eturn -1 if mask intersects the edge of the image.

Parameters:
radius - is mask radius to use (2*radius+1)
x0 - center of the mask'ed data
y0 - center of the mask'ed data
useTotFlag - to return total gray values else mean gray values.
Returns:
sum of pixels values, mapped to OD if map exists, else return -1.0 if therre is a problem.

getPixelValue

public final int getPixelValue(int x,
                               int y)
getPixelValue() - get the pixel value for the image at (x,y). Do not map grayscale to OD. That should be done by the caller.
 Notes: 
 1) because we only keep 24-bit (R,G,B) pixel image data, we only 
    report the least significant 8-bits (blue channel) for the gray value.
 2) If the original image data had > 8-bits, we still report it (for
    now) as 8-bits.

Returns:
grayscale value of pixel, -1 if a problem.

cvtGrayValueToODstr

public java.lang.String cvtGrayValueToODstr(int g)
cvtGrayValueToODstr() - convert gray value to OD string if the map has been defined for the ImageData instance

Parameters:
g - is the gray value to convert
Returns:
converted gray value

getPixelValueStr

public java.lang.String getPixelValueStr(int xObj,
                                         int yObj)
getPixelValueStr() - get the pixel value string for the image where the trial object (xObj,yObj) is located. If the gray to OD map exists, then compute it as OD else grayscale. If we are measuring spots in the spot list and they are viewable, then we can append the spot# and the spot.id (if not null).
 Notes: 
 1) because we only keep 24-bit (R,G,B) pixel image data, we only 
    report the least significant 8-bits (blue channel) for the gray value.
 2) If the original image data had > 8-bits, we still report it (for
    now) as 8-bits.
 3) [TODO] could remap RGB via NTSC mapping...

Parameters:
xObj - pixel coordinate
yObj - pixel coordinate
Returns:
string value of pixel

captureBackgroundValue

public float captureBackgroundValue()
captureBackgroundValue() - capture the values under the mask of the selected image if it is left or right and assign it to the background pixel value for the current image. If calibration is in effect, set the calibrated value.

Returns:
current pixel value, -1 if no image selected

showBkgrdValue

public java.lang.String showBkgrdValue()
showBkgrdValue() - print the background measurement value. These were added using the CTRL-B for background. It sends the string to the output.

Returns:
current background measurement string, null if no data

captureMeasValue

public float captureMeasValue()
captureMeasValue() - capture the pixel values under the mask of the selected image if it is left or right and assign it to the measurement pixel value for the current image. If calibration is in effect, set the calibrated value.

Returns:
current pixel value, -1 if no image selected

captureMeasCWvalue

public float captureMeasCWvalue()
captureMeasCWvalue() - capture the pixel values under the computing window of the selected image if it is left or right and assign it to the measurement pixel value for the current image. If calibration is in effect, set the calibrated value.

Returns:
current pixel value, -1 if no image selected

showMeasValue

public java.lang.String showMeasValue(java.lang.String measMode)
showMeasValue() - print the measurement value subtracting the background value. These were added using the CTRL-B for background and CTRL-M for measure. It sends the string to the output.

Parameters:
measMode - is "circleMask", "compROI", "boundary"
Returns:
current pixel measurement string, null if not data. If measuring spots in the spot list, then set curSpot to the current spot being measured, else set it to null.

calcHistogram

public boolean calcHistogram(int x1,
                             int y1,
                             int x2,
                             int y2)
calcHistogram() - compute grayscale histogram under the specified computing window [x1:x2, y1:y2]. The result is in this.hist[] which is created here.

Parameters:
x1 - - ULHC x coordinate
y1 - - ULHC y coordinate
x2 - - LRHC x coordinate
y2 - - LRHC y coordinate

main

public static void main(java.lang.String[] args)
main() - createMaskDatabase function for debugging...