Class ImageXform

java.lang.Object
  extended by java.lang.Thread
      extended by ImageXform
All Implemented Interfaces:
java.lang.Runnable

public class ImageXform
extends java.lang.Thread

ImageXform class supports image transforms.

ImageXform is the class that does the actual transforms These transforms include affine and polynomial spatial warping, pseudo 3D, sharpening (grad or Laplacian + grayscale), gradient, Laplacian, avg8, complement, etc.. It runs as a background thread. It uses the input image pixel buffer iPix[] from the original image. It creates the output image oPix[] and the output image oImg. The oPix[] buffer is G.C.ed after oImg is created. When done, it calls flk.chkDoneWithTransform to let you know when it's finished.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  Affine aff
          Affine xform instance
(package private) static int AFFINEWARP
          Transform number corresponding to the xfCmd[] table entry.
 int angle
          state copy: angle factor for pseudo3D
private  double[][] aU
          Coefficient for u(x,y) poly warp
(package private) static int AVG8
          Transform number corresponding to the xfCmd[] table entry.
 float bCE
          compute intercept in g'=mCE+bCE
private  BuildGUI bGui
          Build GUI instance
private  double[][] bV
          Coefficient for v(x,y) poly warp
(package private) static int COLOR2GRAY
          Transform number corresponding to the xfCmd[] table entry.
(package private) static int COMPLEMENT
          Transform number corresponding to the xfCmd[] table entry.
(package private) static int CONTR_ENHANCE
          Transform number corresponding to the xfCmd[] table entry.
 ImageScroller curIS
          current ImageScroller right or left
(package private) static int DE_ZOOM
          Transform number corresponding to the xfCmd[] table entry.
 int dX_P3D
          fast (width * sin(thetaRad)
 int eScale
          state copy: scale factor for sharpening xform
 int externFctNbr
          external fct number if > 0
(package private) static int FLIPHORIZ
          Transform number corresponding to the xfCmd[] table entry.
(package private) static int FLIPVERT
          Transform number corresponding to the xfCmd[] table entry.
private  Flicker flk
          main class instance
 int gMax
          compute max grayscale of iPix
 int gMean
          mean of grayscale histogram
 int gMin
          compute min grayscale of iPix
 int gMode
          mode of grayscale histogram
(package private) static int GRAD
          Transform number corresponding to the xfCmd[] table entry.
 int[] gToRGB
          table lookup[256] grayvalue to RGB pixel
 int height
           
 int[] hist
          histogram of iPix[] if needed
(package private) static int HIST_EQUAL
          Transform number corresponding to the xfCmd[] table entry.
 int[] histEq
          equalized histogram of iPix[] if needed
 int i0
          8-neighbor pixels
 int i1
          8-neighbor pixels
 int i2
          8-neighbor pixels
 int i3
          8-neighbor pixels
 int i4
          8-neighbor pixels
 int i5
          8-neighbor pixels
 int i6
          8-neighbor pixels
 int i7
          8-neighbor pixels
 int i8
          8-neighbor pixels
(package private)  ImageData iData
          Image data instance to use we get data from either iImg or oImg
 int[] iPix
           
(package private) static int LAPLACIAN
          Transform number corresponding to the xfCmd[] table entry.
private  Landmark lms
          landmark data
 double mag
          magnification
(package private) static int MAX8
          Transform number corresponding to the xfCmd[] table entry.
 float mCE
          compute slope in g'=mCE+bCE
 int measCircleRadius
          state: measurement circle radius
(package private) static int MEDIAN
          Transform number corresponding to the xfCmd[] table entry.
(package private) static int MIN8
          Transform number corresponding to the xfCmd[] table entry.
(package private)  java.lang.String nameLR
          Image name: "left" or "right" image
 int newHeight
          new magnification size of image for IS
 int newWidth
          new magnification size of image for IS
(package private) static int NORMCOLOR
          Transform number corresponding to the xfCmd[] table entry.
 int nPixels
           
static int nxfCmds
          # of transform commands
 int[] oPix
           
 int origHeight
          original size of image, for zoom
 int origWidth
          original size of image, for zoom
(package private) static int pBlack
           
static int PLUGIN_FCT
          generic plugin transform number is 1 past the last builtin transform
(package private) static int POLYWARP
          Transform number corresponding to the xfCmd[] table entry.
(package private) static int PSEUDO3D
          Transform number corresponding to the xfCmd[] table entry.
(package private) static int PSEUDOCOLOR
          Transform number corresponding to the xfCmd[] table entry.
(package private) static int pWhite
          pixel definitions of white and black
 double scaleFactor
          scale factor for pseudo3D
(package private) static int SHARPENGRAD
          Transform number corresponding to the xfCmd[] table entry.
(package private) static int SHARPENLAPL
          Transform number corresponding to the xfCmd[] table entry.
private  SpatialXform sxf
          poly warp spatial transform
 double thetaRad
          pseudo3D angle in radians
 double thrColinearity
          colinearity threshold
(package private) static int THRESHOLD
          Transform number corresponding to the xfCmd[] table entry.
 int threshold1
          state copy: lower bound threshold for grayscale slicing
 int threshold2
          state copy: upper bound threshold for grayscale slicing
 java.lang.String useXform
          transform to use
private  Util util
          Utility instance
 int width
          iData.iWidth for speedup
static java.lang.String[] xfCmd
          Corresponding builtin transform command names used in the menu action commands.
 int xPrime
           
 int yPrime
           
 int yw
          computed y*width for speedup
 int ywMw
          computed yw-width for speedup
 int ywPw
          computed yw+width for speedup
 float zoomMagVal
          state remapped copy: the zoomMagScr magnification scroller value is mapped using SliderState.cvtZoomMagScr2ZoomMagVal() to this value.
 int zScale
          state copy: Z axis scale factor for pseudo3D
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ImageXform()
          ImageXform() - dummy Construct ImageXform object.
ImageXform(Flicker flk, java.lang.String nameLR, ImageData iData, java.lang.String useXform, int externFctNbr)
          ImageXform() - Construct ImageXform object.
 
Method Summary
 void abortTransform()
          abortTransform() - abort all image transforms in progress.
private  boolean affineWarp()
          affineWarp() - compute Affine Warp of left I1 into geometry of right I2.
private  void avg8()
          avg8() - compute 8-neighbor average
 void cleanup()
          cleanup() - destroy data structures
private  void complement()
          complement() - compute grayscale complement of gI
private  void computeGrayHistStatistics()
          computeGrayHistStatistics() - compute grayscale histogram statistics
private  void contrastEnhance()
          contrastEnhance() - compute grayscale contrast pixel enhancement compute grayscale contrast enhanced image.
 java.awt.Image createZoomedImage()
          createZoomedImage() - create zoomed image using getScaledInstance.
 java.awt.Image createZoomedImage(int[] pixels)
          createZoomedImage() - convert pixel array argument into zoomed image using getScaledInstance.
 void doXform(ImageData iData)
          doXform() - transform iPix[] into oPix[] image data by legal transform Then create the oImg.
private  int findMedian(int[] values)
          findMedian() - compute median of 9 values.
private  void flipHoriz()
          flipHoriz() - compute horizontal flip image Compute 32-bit RGBA pixels from iPix[(x2*height + x2)] in oPix[]
(package private)  void flipVert()
          flipVert() - compute Vertical flip image Compute 32-bit RGBA pixels from iPix[(x2*height + x2)] in oPix[]
private  void gcImageXform(java.lang.String msg)
          gcImageXform() - G.C.
 void getFastNgh(int x1, int y1)
          getFastNgh() - get 3x3 8-bit neighborhood at (x,y)
 void getNgh(int x1, int y1)
          getNgh() - get 3x3 least significant 8-bit neighborhood data at (x,y)
 void getNgh3x3(int x, int y)
          getNgh3x3() - get 3x3 least significant 8-bit neighborhood data at (x,y)
 void getNghInt(int x1, int y1)
          getNghInt() - get 3x3 32-bit neighborhood at (x,y)
 void getNghInt3x3(int x, int y)
          getNghInt3x3() - get 3x3 32-bit neighborhood at (x,y)
private  void grad()
          grad() - compute 4-neighbor gradient
private  void histogramEqualization()
          histogramEqualization() - compute grayscale histogram equalization xform for 8-bit pixels
private  int iabs(int a)
          iabs(a) - compute fastABS of two ints
private  int imax(int a, int b)
          imax(a,b) - compute fast MAX of two ints
private  int imin(int a, int b)
          imin(a,b) - compute fast MIN of two ints
private  void laplacian()
          laplacian() - compute 8-neighbor laplacian
private  void mapXYtoPolyPoint(int x1, int y1)
          mapXYtoPolyPoint() - map PolyWarp xform (xPrime,yPrime) from f(x1,y1) Verifies that (xPrime,yPrime) in width * height else returns (0,0).
private  void mapXYtoPseudo3DPoint(int x1, int y1)
          mapXYtoPseudo3DPoint() - map Pseud3D transform Point(x',y')= f(x,y) Verifies that (x2,y2) in width * height else returns (0,0).
private  void max8()
          max8() - compute max of 8-neighbor pixels for 8-bit data
private  void median8()
          median8() - compute median of 8-neighbors compute pixels in range of [0:255].
private  void min8()
          min8() - compute min of 8-neighbor pixels for 8-bit data
private  void normalColor()
          normalColor() - restore output image to original input image
private  boolean polyWarp()
          polyWarp() - compute Polynomial warp of I1 into I2 as determined by the Polynomial transform warping Xform of iData.
(package private)  boolean pseudo3D()
          pseudo3D() - compute Pseudo 3D by scaling (x',y') by g and angle.
private  void pseudoColor()
          pseudoColor() - compute pseudocolor from grayscale Map 255 to blue and green at 1/2 way, and red 0 for 32-bit pixels
private  boolean remapLMS(java.lang.String imgNameLR, int iOpr)
          remapLMS() - remap LMS if transform changed their positions.
private  boolean remapLMSafterAffine()
          remapLMSafterAffine() - remap LMS since Affine transform changed their positions.
private  void rgb2gray()
          rgb2gray() - convert color image to NTSC gray value image using NTSC transform gray= red*0.33 + green*0.50 + blue*0.17 NOTE: don't apply this transform more than once or it will have bogus results.
 void run()
          run() - Transform the pixels in iPix[] into oPix[] image data by legal transform 'useXform'.
private  void setSyncLockFlag(boolean flag)
          setSyncLockFlag() - set the repaintLockFlag to lock Flicker from repainting while this the flag is true
private  void sharpenGrad()
          sharpenGrad() - Compute add 4-neighbor gradient to grayscale of pixel data
private  void sharpenLaplacian()
          sharpenLaplacian() - Compute add 8-neighbor Laplacian to grayscale of pixel data.
 void softDoneWithTransform(ImageData iData, java.lang.String name, java.lang.String useXformName)
          softDoneWithTransform() - ImageXform thread calls when xform completed.
private  void threshold()
          threshold() - compute grayscale threshold of gI gO= (gI<=t2 && gI>=t1) ? gI : pWhite; compute thresholded 8-bit pixel
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

flk

private Flicker flk
main class instance


aff

private Affine aff
Affine xform instance


bGui

private BuildGUI bGui
Build GUI instance


lms

private Landmark lms
landmark data


sxf

private SpatialXform sxf
poly warp spatial transform


util

private Util util
Utility instance


nameLR

java.lang.String nameLR
Image name: "left" or "right" image


iData

ImageData iData
Image data instance to use we get data from either iImg or oImg


xfCmd

public static java.lang.String[] xfCmd
Corresponding builtin transform command names used in the menu action commands.


nxfCmds

public static int nxfCmds
# of transform commands


SHARPENGRAD

static final int SHARPENGRAD
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

SHARPENLAPL

static final int SHARPENLAPL
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

GRAD

static final int GRAD
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

LAPLACIAN

static final int LAPLACIAN
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

AVG8

static final int AVG8
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

COMPLEMENT

static final int COMPLEMENT
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

CONTR_ENHANCE

static final int CONTR_ENHANCE
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

HIST_EQUAL

static final int HIST_EQUAL
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

MEDIAN

static final int MEDIAN
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

MAX8

static final int MAX8
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

MIN8

static final int MIN8
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

THRESHOLD

static final int THRESHOLD
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

PSEUDO3D

static final int PSEUDO3D
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

AFFINEWARP

static final int AFFINEWARP
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

POLYWARP

static final int POLYWARP
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

FLIPHORIZ

static final int FLIPHORIZ
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

FLIPVERT

static final int FLIPVERT
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

NORMCOLOR

static final int NORMCOLOR
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

PSEUDOCOLOR

static final int PSEUDOCOLOR
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

COLOR2GRAY

static final int COLOR2GRAY
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

DE_ZOOM

static final int DE_ZOOM
Transform number corresponding to the xfCmd[] table entry. !!!! KEEP THISE NUMBERS SYNCED!!!!!

See Also:
Constant Field Values

PLUGIN_FCT

public static int PLUGIN_FCT
generic plugin transform number is 1 past the last builtin transform


pWhite

static final int pWhite
pixel definitions of white and black

See Also:
Constant Field Values

pBlack

static final int pBlack
See Also:
Constant Field Values

i0

public int i0
8-neighbor pixels


i1

public int i1
8-neighbor pixels


i2

public int i2
8-neighbor pixels


i3

public int i3
8-neighbor pixels


i4

public int i4
8-neighbor pixels


i5

public int i5
8-neighbor pixels


i6

public int i6
8-neighbor pixels


i7

public int i7
8-neighbor pixels


i8

public int i8
8-neighbor pixels


useXform

public java.lang.String useXform
transform to use


externFctNbr

public int externFctNbr
external fct number if > 0


gToRGB

public int[] gToRGB
table lookup[256] grayvalue to RGB pixel


angle

public int angle
state copy: angle factor for pseudo3D


zScale

public int zScale
state copy: Z axis scale factor for pseudo3D


eScale

public int eScale
state copy: scale factor for sharpening xform


dX_P3D

public int dX_P3D
fast (width * sin(thetaRad)


threshold1

public int threshold1
state copy: lower bound threshold for grayscale slicing


threshold2

public int threshold2
state copy: upper bound threshold for grayscale slicing


zoomMagVal

public float zoomMagVal
state remapped copy: the zoomMagScr magnification scroller value is mapped using SliderState.cvtZoomMagScr2ZoomMagVal() to this value.


measCircleRadius

public int measCircleRadius
state: measurement circle radius


hist

public int[] hist
histogram of iPix[] if needed


histEq

public int[] histEq
equalized histogram of iPix[] if needed


gMean

public int gMean
mean of grayscale histogram


gMode

public int gMode
mode of grayscale histogram


gMax

public int gMax
compute max grayscale of iPix


gMin

public int gMin
compute min grayscale of iPix


mCE

public float mCE
compute slope in g'=mCE+bCE


bCE

public float bCE
compute intercept in g'=mCE+bCE


yw

public int yw
computed y*width for speedup


ywMw

public int ywMw
computed yw-width for speedup


ywPw

public int ywPw
computed yw+width for speedup


origWidth

public int origWidth
original size of image, for zoom


origHeight

public int origHeight
original size of image, for zoom


newWidth

public int newWidth
new magnification size of image for IS


newHeight

public int newHeight
new magnification size of image for IS


width

public int width
iData.iWidth for speedup


height

public int height

nPixels

public int nPixels

xPrime

public int xPrime

yPrime

public int yPrime

oPix

public int[] oPix

iPix

public int[] iPix

scaleFactor

public double scaleFactor
scale factor for pseudo3D


thrColinearity

public double thrColinearity
colinearity threshold


thetaRad

public double thetaRad
pseudo3D angle in radians


aU

private double[][] aU
Coefficient for u(x,y) poly warp


bV

private double[][] bV
Coefficient for v(x,y) poly warp


curIS

public ImageScroller curIS
current ImageScroller right or left


mag

public double mag
magnification

Constructor Detail

ImageXform

public ImageXform()
ImageXform() - dummy Construct ImageXform object.


ImageXform

public ImageXform(Flicker flk,
                  java.lang.String nameLR,
                  ImageData iData,
                  java.lang.String useXform,
                  int externFctNbr)
ImageXform() - Construct ImageXform object.

Parameters:
flk - instance
nameLR - is the image "left" or "right"
iData - image data input/output images
useXform - is name of transform to perform
externFctNbr - perform extern function if not zero
Method Detail

setSyncLockFlag

private void setSyncLockFlag(boolean flag)
setSyncLockFlag() - set the repaintLockFlag to lock Flicker from repainting while this the flag is true


cleanup

public void cleanup()
cleanup() - destroy data structures


run

public void run()
run() - Transform the pixels in iPix[] into oPix[] image data by legal transform 'useXform'. Then create oImg to be displayed.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

abortTransform

public void abortTransform()
abortTransform() - abort all image transforms in progress. Handle the case where there is another transform in progress. Clear flags and adjust counters to reflect killing this transform.


softDoneWithTransform

public void softDoneWithTransform(ImageData iData,
                                  java.lang.String name,
                                  java.lang.String useXformName)
softDoneWithTransform() - ImageXform thread calls when xform completed. ImageXform sets iData to either iData1 or iData2. At that point we can create an image from the output oPix data and repaint it. If flk.composeXformFlag is set, then using original image which may have changed.

Parameters:
iData - is the image data
name - of transform
See Also:
Flicker.chkDoneWithTransform()

imax

private final int imax(int a,
                       int b)
imax(a,b) - compute fast MAX of two ints

Parameters:
a - is arg
b - is arg
Returns:
MAX(a,b)

imin

private final int imin(int a,
                       int b)
imin(a,b) - compute fast MIN of two ints

Parameters:
a - is arg
b - is arg
Returns:
MIN(a,b)

iabs

private final int iabs(int a)
iabs(a) - compute fastABS of two ints

Parameters:
a - is arg
b - is arg
Returns:
ABS(a)

remapLMS

private boolean remapLMS(java.lang.String imgNameLR,
                         int iOpr)
remapLMS() - remap LMS if transform changed their positions. Note: if ever Restore I1 & I2 images, then wipe out landmarks so don't need to remap in that case.
 [NOTE] there are two sets of landmarks in the lms object:
  lms.{xy}{12}[lm#] for the iImg
 and
  lms.o{xy}{12}[lm#] for the oImg.
 The ImageScroller displays the landmarks from oImg if there is 
 valid oImg object and otherwise uses the landmarks for iImg.

Parameters:
imgNameLR - is "left", "right" or "both" to remap
iOpr - affine operator: AFFINEWARP, POLYWARP or PSEUDO3D
Returns:
true if succeed

remapLMSafterAffine

private boolean remapLMSafterAffine()
remapLMSafterAffine() - remap LMS since Affine transform changed their positions. [DEPRICATE] after get remapLMS() working 100%...

Parameters:
iOpr - affine operator: AFFINEWARP, POLYWARP or PSEUDO3D
Returns:
true if succeed

getFastNgh

public final void getFastNgh(int x1,
                             int y1)
getFastNgh() - get 3x3 8-bit neighborhood at (x,y)
   i3 i2 i1
   i4 i8 i0
   i5 i6 i7
Note: if the neighborhood is on the edge, then return 0 ngh. [NOTE] It is assumed that the image is 8-bit gray scale, so r==b==g. [TODO] If not, we should map it to gray somehow. [TODO] Need to ***DEBUG*** - does not work.

Parameters:
x1 - center of neighborhood
y1 - center of neighborhood

getNgh3x3

public final void getNgh3x3(int x,
                            int y)
getNgh3x3() - get 3x3 least significant 8-bit neighborhood data at (x,y)
   i3 i2 i1
   i4 i8 i0
   i5 i6 i7
 [NOTES]
 1. If the neighborhood is on the edge, then return 0 ngh.
 2. It is assumed that the image is gray scale, so r==b==g.
 3. If not, we could map it to gray using NTSC RGB to gray transform.
 4. Assume that state vars (yw, ywMw, ywPw) are precomputed BEFORE
    calling this method.

Parameters:
x - center of neighborhood
y - center of neighborhood

getNgh

public final void getNgh(int x1,
                         int y1)
getNgh() - get 3x3 least significant 8-bit neighborhood data at (x,y)
   i3 i2 i1
   i4 i8 i0
   i5 i6 i7
 [NOTES]
 1. If the neighborhood is on the edge, then return 0 ngh.
 2. It is assumed that the image is gray scale, so r==b==g.
 3. If not, we could map it to gray using NTSC RGB to gray transform.
 4. Assume that state vars (yw, ywMw, ywPw) are precomputed BEFORE
    calling this method.

Parameters:
x1 - center of neighborhood
y1 - center of neighborhood

getNghInt3x3

public final void getNghInt3x3(int x,
                               int y)
getNghInt3x3() - get 3x3 32-bit neighborhood at (x,y)
   i3 i2 i1
   i4 i8 i0
   i5 i6 i7
 [NOTES]
 1. If the neighborhood is on the edge, then return 0 ngh.
 2. Assume that state vars (yw, ywMw, ywPw) are precomputed BEFORE
    calling this method.

Parameters:
x - center of neighborhood
y - center of neighborhood

getNghInt

public final void getNghInt(int x1,
                            int y1)
getNghInt() - get 3x3 32-bit neighborhood at (x,y)
   i3 i2 i1
   i4 i8 i0
   i5 i6 i7
 [NOTES]
 1. If the neighborhood is on the edge, then return 0 ngh.
 2. Assume that state vars (yw, ywMw, ywPw) are precomputed BEFORE
    calling this method.

Parameters:
x1 - center of neighborhood
y1 - center of neighborhood

sharpenGrad

private final void sharpenGrad()
sharpenGrad() - Compute add 4-neighbor gradient to grayscale of pixel data
  3 2 1       -1  0 +1      +1 +2 +1        0 +1 +2        +2 +1  0
  4 8 0   dO= -2  0 +2, d90= 0  0  0, d45= -1  0 +1, d135= +1  0 -1
  5 6 7       -1  0 +1      -1 -2 -1       -2 -1  0         0 -1 -2

    grad= max(d0, d45, d90, d135)
    sharpenGrad= (i8 + (eScale*grad)/100).
    sharpenGrad= ((100-eScale)*i8 + eScale*grad)/100.
 Compute pixels in range of [0:255].


sharpenLaplacian

private final void sharpenLaplacian()
sharpenLaplacian() - Compute add 8-neighbor Laplacian to grayscale of pixel data.
   3 2 1     -1 -1 -1
   4 8 0     -1 +8 -1
   5 6 7     -1 -1 -1

    laplacian= (255 - abs((8*i8 - (i0+i1+i2+i3+i4+i5+i6+i7)), 0))
    sharpenLaplacian= (i8 + (eScale*laplacian)/100)
    sharpenLaplacian= ((100-eScale)*i8 + eScale*laplacian)/100
 Compute pixels in range of [0:255].


grad

private final void grad()
grad() - compute 4-neighbor gradient
  3 2 1       -1  0 +1      +1 +2 +1        0 +1 +2        +2 +1  0
  4 8 0   dO= -2  0 +2, d90= 0  0  0, d45= -1  0 +1, d135= +1  0 -1
  5 6 7       -1  0 +1      -1 -2 -1       -2 -1  0         0 -1 -2

     grad= max(d0, d45, d90, d135)
 Compute pixels in range of [0:255].


laplacian

private final void laplacian()
laplacian() - compute 8-neighbor laplacian
   3 2 1     -1 -1 -1
   4 8 0     -1 +8 -1
   5 6 7     -1 -1 -1

    laplacian= (255 - abs((8*i8 - (i0+i1+i2+i3+i4+i5+i6+i7)), 0))
 Compute pixels in range of [0:255].


avg8

private final void avg8()
avg8() - compute 8-neighbor average
   3 2 1
   4 8 0
   5 6 7

     avg8= (i0+i1+i2+i3+i4+i5+i6+i7+i8)/9);
 compute pixels in range of [0:255].


findMedian

private final int findMedian(int[] values)
findMedian() - compute median of 9 values. Finds the 5th largest of 9 values.

Parameters:
values - to compute median [0:8]
Returns:
median value.

median8

private final void median8()
median8() - compute median of 8-neighbors compute pixels in range of [0:255].


max8

private final void max8()
max8() - compute max of 8-neighbor pixels for 8-bit data
   3 2 1
   4 8 0
   5 6 7

     max8= max(i0,i1,i2,i3,i4,i5,i6,i7,i8));
 compute pixels in range of [0:255].


min8

private final void min8()
min8() - compute min of 8-neighbor pixels for 8-bit data
   3 2 1
   4 8 0
   5 6 7

     min8= min(i0,i1,i2,i3,i4,i5,i6,i7,i8));
 compute pixels in range of [0:255].


complement

private final void complement()
complement() - compute grayscale complement of gI
     gO= (255 - gI)
 compute complemented 8-bit pixel


threshold

private final void threshold()
threshold() - compute grayscale threshold of gI gO= (gI<=t2 && gI>=t1) ? gI : pWhite; compute thresholded 8-bit pixel


contrastEnhance

private final void contrastEnhance()
contrastEnhance() - compute grayscale contrast pixel enhancement compute grayscale contrast enhanced image.


histogramEqualization

private final void histogramEqualization()
histogramEqualization() - compute grayscale histogram equalization xform for 8-bit pixels


normalColor

private final void normalColor()
normalColor() - restore output image to original input image


pseudoColor

private final void pseudoColor()
pseudoColor() - compute pseudocolor from grayscale Map 255 to blue and green at 1/2 way, and red 0 for 32-bit pixels


rgb2gray

private final void rgb2gray()
rgb2gray() - convert color image to NTSC gray value image using NTSC transform gray= red*0.33 + green*0.50 + blue*0.17 NOTE: don't apply this transform more than once or it will have bogus results. Could overide iPix that could be oPix so it uses the iData.iPix data.


createZoomedImage

public java.awt.Image createZoomedImage()
createZoomedImage() - create zoomed image using getScaledInstance. The image used is the one used for zoomed input using the getImageForZoomInput() that could be either (iImg, oImg).

Returns:
zoomed image

createZoomedImage

public java.awt.Image createZoomedImage(int[] pixels)
createZoomedImage() - convert pixel array argument into zoomed image using getScaledInstance.

Parameters:
pixels -
Returns:
zoomed image

affineWarp

private final boolean affineWarp()
affineWarp() - compute Affine Warp of left I1 into geometry of right I2. Or right I2 into geometry of left I1 image. The image to transform is determined by the Affine Xform of iData. This assumes the transform coefficients were set up using the Affine class.

This is a reverse transform so there are no gaps in output image unless it maps to outside of the input image. compute 8-bit pixels mapped from iPix data.


polyWarp

private final boolean polyWarp()
polyWarp() - compute Polynomial warp of I1 into I2 as determined by the Polynomial transform warping Xform of iData. This assumes that the PolyWarp class was setup previously. This is a reverse transform so there are no gaps in output image unless it maps to outside of the input image. Return 32-bit RGBA pixels mapped from iPix data in oPix[]


mapXYtoPolyPoint

private final void mapXYtoPolyPoint(int x1,
                                    int y1)
mapXYtoPolyPoint() - map PolyWarp xform (xPrime,yPrime) from f(x1,y1) Verifies that (xPrime,yPrime) in width * height else returns (0,0). (xPrime,yPrime) mapped loc to get iPix[] data.

Parameters:
x1 - to map
y1 - to map

flipHoriz

private final void flipHoriz()
flipHoriz() - compute horizontal flip image Compute 32-bit RGBA pixels from iPix[(x2*height + x2)] in oPix[]


flipVert

final void flipVert()
flipVert() - compute Vertical flip image Compute 32-bit RGBA pixels from iPix[(x2*height + x2)] in oPix[]


pseudo3D

final boolean pseudo3D()
pseudo3D() - compute Pseudo 3D by scaling (x',y') by g and angle. Verifies that (x2,y2) in width * height else returns 0. This is a forward transform which means there may be gaps in the output image. Computes 32-bit RGBA pixels from iPix[(x2*height + x2)] in oPix[]

Returns:
true if succeed

mapXYtoPseudo3DPoint

private final void mapXYtoPseudo3DPoint(int x1,
                                        int y1)
mapXYtoPseudo3DPoint() - map Pseud3D transform Point(x',y')= f(x,y) Verifies that (x2,y2) in width * height else returns (0,0). Compute Point(x2,y2) in (xPrime,yPrime)


computeGrayHistStatistics

private final void computeGrayHistStatistics()
computeGrayHistStatistics() - compute grayscale histogram statistics


doXform

public void doXform(ImageData iData)
doXform() - transform iPix[] into oPix[] image data by legal transform Then create the oImg. Then GC whatever we don't need.

Parameters:
iData - the image to transform

gcImageXform

private void gcImageXform(java.lang.String msg)
gcImageXform() - G.C. the image transform variables