Class AlgorithmCircularSectorToRectangle
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmCircularSectorToRectangle
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmCircularSectorToRectangle extends AlgorithmBase
This software uses 2D conformal mapping in converting a circular sector defined by 4 user points at the sector corners to a rectangle of user specified size. The circular sector has an inner radius rmin, an outer radius rmax, and extends over an angle theta = alpha * PI radians, with 0 < alpha <= 1. In a conformal mapping in any small neighborhood the relative angle and shape are preserved. The points z1, z2, z3, and z4 are entered in a counterclockwise order with z1 and z2 on rmax and z3 and z4 on rmin. For the case of rmax pointing to the top of the image, z1 is the upper right point on rmax, z2 is the upper left point on rmax, z3 is the lower left point on rmin, and z4 is the lower right point on rmin. The mapping to the user specified rectangle is performed in 3 steps. First, all distances from the circular center are divided by sqrt(rmax * rmin). Second, a conformal mapping to a rectangle of width 1 and height log(rmax/rmin)/theta occurs. Then, this rectangle is linearly scaled to a rectangle of user specified xDim and yDim. Note that the linear scaling of one rectangle to another is not a conformal mapping unless the width and height are scaled by the same factor. From "Lectures on Quasiconformal Mappings" second edition by Lars V. Ahlfors: "If Q is a square and R is a rectangle, not a square, there is no conformal mapping of Q on R which maps vertices on vertices."Let z4z1 be on the real axis, let the straight line z2z3 be inclined at an angle alpha*PI, 0 < alpha <= 1, z3 and z4 are both on the radius rmin, and z1 and z2 are both on the radius rmax. For the conformal mapping we require that rmax > 1 and 0 < rmin < 1. So divide all the distances by sqrt(rmax * rmin). Then the radii go from sqrt(rmin/rmax) to sqrt(rmax/rmin).
To go from a circular sector to a rectangle use the transformation w = f(z) = u + iv = log(z)/(i*alpha*PI) Let z = r*exp(i*theta) Then, w = log(r*exp(i*theta))/(i*alpha*PI) = theta/(alpha*PI) - i*log(r)/(alpha*PI) so u = theta/(alpha*PI), v = -log(r)/(alpha*PI)
For conformal mapping we require that f(z) be analytic - the Cauchy-Riemann equations must be satisfied and f'(z) must not equal zero. The Cauchy-Riemann equations in polar form are: du/dr = (1/r)(dv/dtheta); (1/r)du/dtheta = -dv/dr The first equation gives zero on both sides and the second equation gives (alpha*PI)/r on both sides, so the Cauchy Riemann equations hold. f'(z) = 1/(i*alpha*PI*z) does not equal zero.
In the first mapping: rmin -> sqrt(rmin/rmax) -> log(sqrt(rmin/rmax))/(i*alpha*PI) = i*log(sqrt(rmax/rmin))/(alpha*PI) rmin*exp(i*alpha*PI) -> sqrt(rmin/rmax)*exp(i*alpha*PI) -> 1 + i*log(sqrt(rmax/rmin))/(alpha*PI) rmax -> sqrt(rmax/rmin) -> log(sqrt(rmax/rmin))/(i*alpha*PI) = -i*log(sqrt(rmax/rmin))/(alpha*PI) rmax*exp(i*alpha*PI) -> sqrt(rmax/rmin)*exp(i*alpha*PI) -> 1 - i*log(sqrt(rmax/rmin))/(alpha*PI)
Now do a simple linear transformation where both the x axis is inverted and both axes are scaled to obtain: z1" = xDim-1, 0 z2" = 0, 0 z3" = 0, yDim-1 z4" = xDim - 1, yDim-1
x" = (1 - x')*(xDim - 1) Let var = log(sqrt(rmax/rmin))/(alpha*PI) y" = (y' + var)* (yDim - 1)/(2 * var)
A similar transformation is performed in Conformal Mapping by Zeev Nehari Chapter VI Mapping Properties of Special Functions 2. Exponential and Trigonometric Functios pp. 273-280. Nehari states that "the transformation w = exp(z) maps the boundary of any rectangle in the z-plane whose sides are parallel to the axes onto a closed contour consisting of two circular arcs about the origin and two linear segments pointing at the origin."References: 1.) Advanced Calculus For Applications Second Edition by F. B. Hildebrand, Section 10.4 Analytic Functions of a Complex Variable pages 550-554 and Section 11.4 Conformal Mapping pages 628-632, Prentice-Hall, Inc., 1976. 2.) "A Domain Decomposition Method for Conformal Mapping onto a Rectangle", N. Papamichael and N. S. Stylianopoulos, Constructive Approximation, Vol. 7, 1991, pp. 349-379. Relevant result is given in Remark 4.7 on pages 374-375.
3.) Conformal Mapping by Zeev Nehari Chapter VI Mapping Properties of Special Functions 2. Exponential and Trigonometric Functions pp. 273-280.
-
-
Field Summary
Fields Modifier and Type Field Description private int
testBottom
private int
testLeft
private int
testOrientation
private int
testRight
private int
testTop
private double[]
x
DOCUMENT ME!private double[]
y
DOCUMENT ME!-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description AlgorithmCircularSectorToRectangle()
AlgorithmCircularSectorToRectangle - default constructor.AlgorithmCircularSectorToRectangle(ModelImage destImg, ModelImage srcImg, double[] x, double[] y)
AlgorithmCircularSectorToRectangle.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finalize()
finalize -void
runAlgorithm()
Starts the program.private void
selfTest()
private void
selfTest2()
private void
selfTest3()
-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
x
private double[] x
DOCUMENT ME!
-
y
private double[] y
DOCUMENT ME!
-
testOrientation
private int testOrientation
-
testTop
private final int testTop
- See Also:
- Constant Field Values
-
testBottom
private final int testBottom
- See Also:
- Constant Field Values
-
testRight
private final int testRight
- See Also:
- Constant Field Values
-
testLeft
private final int testLeft
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AlgorithmCircularSectorToRectangle
public AlgorithmCircularSectorToRectangle()
AlgorithmCircularSectorToRectangle - default constructor.
-
AlgorithmCircularSectorToRectangle
public AlgorithmCircularSectorToRectangle(ModelImage destImg, ModelImage srcImg, double[] x, double[] y)
AlgorithmCircularSectorToRectangle.- Parameters:
destImg
- DOCUMENT ME!srcImg
- DOCUMENT ME!x
- array with x coordinates of 4 sector boundary pointsy
- array with y coordinates of 4 sector boundary points
-
-
Method Detail
-
finalize
public void finalize()
finalize -- Overrides:
finalize
in classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
Starts the program.- Specified by:
runAlgorithm
in classAlgorithmBase
-
selfTest
private void selfTest()
-
selfTest2
private void selfTest2()
-
selfTest3
private void selfTest3()
-
-