|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectAffine
public class Affine
The Affine class does affine transform setup and pixel operations.
Given 3 landmarks (lm1,lm2,lm3) for the two images, solve the linear transforms for (a,b,c,d,e,f) x2= a*x1 + b*y1 +c y2= d*x1 + e*y1 +f Then also solve the inverse transform (a0,b0,c0,e0,f0). This lets us map pixels at location (x,y) in one image to the corresponding location (x',y') in the other image. NOTE: it will fail if the landmarks are co-linear.
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
Field Summary | |
---|---|
float |
a
coeff for x2= a*x + b*y1 + c |
float |
a0
inverse coefficient for x2= aO*x1 + bO*y1 + cO |
static java.lang.String |
affine_calcsString
affine xform calculations |
float |
b
coeff for x2= a*x1 + b*y1 + c |
float |
b0
inverse coefficient for x2= aO*x1 + bO*y1 + cO |
float |
c
coeff for x2= a*x1 + b*y1 + c |
float |
c0
inverse coefficient for x2= aO*x1 + bO*y1 + cO |
float |
d
coeff for y2= d*x1 + e*y1 + f |
float |
d0
inverse coefficient for y2= dO*x1 + eO*y1 + fO |
float |
e
coeff for y2= d*x1 + e*y1 + f |
float |
e0
inverse coefficient for y2= dO*x1 + eO*y1 + fO |
java.lang.String |
errMsg
accumulated error messages |
float |
f
coeff for y2= d*x1 + e*y1 + f |
float |
f0
inverse coefficient for y2= dO*x1 + eO*y1 + fO |
private Flicker |
flk
Global instance |
private int |
height
Image height |
private boolean |
isFlipLMSflag
flip left and right landmarks after copy to local [FUTURE] |
private boolean |
isValidLMSflag
Landmark DB has 3 valid landmarks. |
int |
lm1
indices of three landmarks |
int |
lm2
indices of three landmarks |
int |
lm3
indices of three landmarks |
float |
minLSQcolinearity1
LSQ colinearity err for I1 lms wrt I1 |
float |
minLSQcolinearity2
LSQ colinearity error for I2 lms wrt I2 |
float |
thrColinearity
threshold for colinearity tests |
private int |
width
Image width |
private float |
x11
|
private float |
x12
|
private float |
x13
|
private float |
x21
|
private float |
x22
|
private float |
x23
|
private float |
y11
|
private float |
y12
|
private float |
y13
|
private float |
y21
|
private float |
y22
|
private float |
y23
|
Constructor Summary | |
---|---|
Affine(Flicker flk)
Affine() - constructor which sets up the global links |
Method Summary | |
---|---|
boolean |
calcInverseAffine()
calcInverseAffine() - compute inverse affine coefficients. |
float |
colinearityLSQerr(int useImgNbr)
colinearityLSQerr() - compute colinearity of 3 landmarks as LSQ error. |
private void |
flipLMS()
flipLMS() - flip the local copy of the 3 landmarks |
java.lang.String |
getAffineCalcsString()
|
float[] |
getAffineCoef()
getAffineCoef() - return array with [a,b,c,d,e,f] |
float |
getAffineMLSQcolinearity(int idx)
getAffineMLSQcolinearity() - get landmark colinearity. |
float[] |
getINVAffineCoef()
getINVAffineCoef() - return array with [aO,bO,cO,dO,eO,fO] |
private java.lang.String |
getLMstr()
getLMstr() - return the 3 landmark values for I1 and I2 |
void |
initAffine(float thrColinearity,
int width,
int height)
initAffine() - init the affine instance for another transform. |
void |
initDefaultState()
initDefaultState() - Initialize affine state to no transform present. |
int |
mapXYtoAffineIdx(int x,
int y)
mapXYtoAffineIdx() - Compute Affine transform (x',y') idx from f(x,y) where idx is the index of the pixel in the input image to be used for the output image. |
int |
mapXYtoAffineX(int x,
int y)
mapXYtoAffineX() - Compute Affine transform x' from f(x,y) to be used for the output image. |
int |
mapXYtoAffineY(int x,
int y)
mapXYtoAffineY() - Compute Affine transform y' from f(x,y) to be used for the output image. |
int |
mapXYtoInvAffineX(int x,
int y)
mapXYtoInvAffineX() - Compute Inverse Affine transform x'= f(x,y) to be used for the output image. |
int |
mapXYtoInvAffineY(int x,
int y)
mapXYtoInvAffineY() - Compute Inverse Affine transform y' from f(x,y) to be used for the output image. |
java.lang.String |
setLMSindexes(int lm1,
int lm2,
int lm3,
boolean isFlipLMSflag)
setLMSindexes() - set the 3 landmark indexes (lm1,lm2,lm3) into the landmark stack where nLM should be >=3. |
java.lang.String |
showAffineCalcs()
showAffineCalcs() - show affine calculations string report. |
java.lang.String |
showAffineLM(java.lang.String msg)
showAffineLM() - show affine Landmarks |
java.lang.String |
solveAffineXform()
solveAffineXform() - compute the affine transformation for 3 LM of the 3 landmarks and return a dynamically allocated affine object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Flicker flk
public static java.lang.String affine_calcsString
private int width
private int height
public float a
public float b
public float c
public float d
public float e
public float f
public float a0
public float b0
public float c0
public float d0
public float e0
public float f0
public float thrColinearity
public float minLSQcolinearity1
public float minLSQcolinearity2
public java.lang.String errMsg
public int lm1
public int lm2
public int lm3
private boolean isFlipLMSflag
private boolean isValidLMSflag
private float x11
private float x12
private float x13
private float y11
private float y12
private float y13
private float x21
private float x22
private float x23
private float y21
private float y22
private float y23
Constructor Detail |
---|
public Affine(Flicker flk)
flk
- is main classMethod Detail |
---|
public void initAffine(float thrColinearity, int width, int height)
thrColinearity
- thresholdwidth
- of mapping imageheight
- of mapping imagepublic void initDefaultState()
public final float[] getAffineCoef()
public final float[] getINVAffineCoef()
public final float getAffineMLSQcolinearity(int idx)
idx
- is the landmark set to use (1 or 2)
private void flipLMS()
public final java.lang.String setLMSindexes(int lm1, int lm2, int lm3, boolean isFlipLMSflag)
lm1
- is 1st landmark to use, LM# are >0lm2
- is 2nd landmark to use LM# are >0lm3
- is 3rd landmark to use LM# are >0
public final boolean calcInverseAffine()
public float colinearityLSQerr(int useImgNbr)
useImgNbr
- to use (1 or 2)
public java.lang.String getAffineCalcsString()
private java.lang.String getLMstr()
public java.lang.String showAffineLM(java.lang.String msg)
public final java.lang.String solveAffineXform()
This solves the 2 simultaneous equations for (a,b,c,d,e,f): x2= a*x1 + b*y1 + c y2= d*x1 + e*y1 + f given the three landmarks. * [TODO] - check calculations since coeffients look wierd...
public final int mapXYtoAffineIdx(int x, int y)
This assumes that the coefficients exist. x'= a*x + b*y + c, y'= d*x + e*y + f, idxA= (y'*width + x') Then, compute gO= inputPixels[idxA]
x
- to mapy
- to map
public final int mapXYtoInvAffineX(int x, int y)
This assumes that the coefficients exist. x'= aO*x + bO*y + cO,
x
- to mapy
- to mappublic final int mapXYtoInvAffineY(int x, int y)
This assumes that the coefficients exist. y'= dO*x + eO*y + fO,
x
- to mapy
- to map
public final int mapXYtoAffineX(int x, int y)
This assumes that the coefficients exist. x'= a*x + b*y + c,
x
- to mapy
- to map
public final int mapXYtoAffineY(int x, int y)
This assumes that the coefficients exist. y'= d*x + e*y + f,
x
- to mapy
- to map
public java.lang.String showAffineCalcs()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |