|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread ImageXform
public class ImageXform
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
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 |
---|
private Flicker flk
private Affine aff
private BuildGUI bGui
private Landmark lms
private SpatialXform sxf
private Util util
java.lang.String nameLR
ImageData iData
public static java.lang.String[] xfCmd
public static int nxfCmds
static final int SHARPENGRAD
static final int SHARPENLAPL
static final int GRAD
static final int LAPLACIAN
static final int AVG8
static final int COMPLEMENT
static final int CONTR_ENHANCE
static final int HIST_EQUAL
static final int MEDIAN
static final int MAX8
static final int MIN8
static final int THRESHOLD
static final int PSEUDO3D
static final int AFFINEWARP
static final int POLYWARP
static final int FLIPHORIZ
static final int FLIPVERT
static final int NORMCOLOR
static final int PSEUDOCOLOR
static final int COLOR2GRAY
static final int DE_ZOOM
public static int PLUGIN_FCT
static final int pWhite
static final int pBlack
public int i0
public int i1
public int i2
public int i3
public int i4
public int i5
public int i6
public int i7
public int i8
public java.lang.String useXform
public int externFctNbr
public int[] gToRGB
public int angle
public int zScale
public int eScale
public int dX_P3D
public int threshold1
public int threshold2
public float zoomMagVal
public int measCircleRadius
public int[] hist
public int[] histEq
public int gMean
public int gMode
public int gMax
public int gMin
public float mCE
public float bCE
public int yw
public int ywMw
public int ywPw
public int origWidth
public int origHeight
public int newWidth
public int newHeight
public int width
public int height
public int nPixels
public int xPrime
public int yPrime
public int[] oPix
public int[] iPix
public double scaleFactor
public double thrColinearity
public double thetaRad
private double[][] aU
private double[][] bV
public ImageScroller curIS
public double mag
Constructor Detail |
---|
public ImageXform()
public ImageXform(Flicker flk, java.lang.String nameLR, ImageData iData, java.lang.String useXform, int externFctNbr)
flk
- instancenameLR
- is the image "left" or "right"iData
- image data input/output imagesuseXform
- is name of transform to performexternFctNbr
- perform extern function if not zeroMethod Detail |
---|
private void setSyncLockFlag(boolean flag)
public void cleanup()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void abortTransform()
public void softDoneWithTransform(ImageData iData, java.lang.String name, java.lang.String useXformName)
iData
- is the image dataname
- of transformFlicker.chkDoneWithTransform()
private final int imax(int a, int b)
a
- is argb
- is arg
private final int imin(int a, int b)
a
- is argb
- is arg
private final int iabs(int a)
a
- is argb
- is arg
private boolean remapLMS(java.lang.String imgNameLR, int iOpr)
[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.
imgNameLR
- is "left", "right" or "both" to remapiOpr
- affine operator: AFFINEWARP, POLYWARP or PSEUDO3D
private boolean remapLMSafterAffine()
iOpr
- affine operator: AFFINEWARP, POLYWARP or PSEUDO3D
public final void getFastNgh(int x1, int y1)
i3 i2 i1 i4 i8 i0 i5 i6 i7Note: 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.
x1
- center of neighborhoody1
- center of neighborhoodpublic final void getNgh3x3(int x, int 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.
x
- center of neighborhoody
- center of neighborhoodpublic final void getNgh(int x1, int y1)
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.
x1
- center of neighborhoody1
- center of neighborhoodpublic final void getNghInt3x3(int x, int 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.
x
- center of neighborhoody
- center of neighborhoodpublic final void getNghInt(int x1, int y1)
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.
x1
- center of neighborhoody1
- center of neighborhoodprivate final void sharpenGrad()
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].
private final void sharpenLaplacian()
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].
private final void grad()
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].
private final void 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].
private final void avg8()
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].
private final int findMedian(int[] values)
values
- to compute median [0:8]
private final void median8()
private final void max8()
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].
private final void min8()
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].
private final void complement()
gO= (255 - gI) compute complemented 8-bit pixel
private final void threshold()
private final void contrastEnhance()
private final void histogramEqualization()
private final void normalColor()
private final void pseudoColor()
private final void rgb2gray()
public java.awt.Image createZoomedImage()
public java.awt.Image createZoomedImage(int[] pixels)
pixels
-
private final boolean affineWarp()
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.
private final boolean polyWarp()
private final void mapXYtoPolyPoint(int x1, int y1)
x1
- to mapy1
- to mapprivate final void flipHoriz()
final void flipVert()
final boolean pseudo3D()
private final void mapXYtoPseudo3DPoint(int x1, int y1)
private final void computeGrayHistStatistics()
public void doXform(ImageData iData)
iData
- the image to transformprivate void gcImageXform(java.lang.String msg)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |