Package gov.nih.mipav.model.algorithms
Class AlgorithmBarrelDistortion
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmBarrelDistortion
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmBarrelDistortion extends AlgorithmBase
Corrects barrel and/or pin cushion distortion for 2D images. rsrc = a * rdest**4 + b * rdest**3 + c * rdest**2 + d * rdest rsrc and rdest are specified in units of the min((xDim-1)/2, (yDim-1)/2) Reference 1.) Correcting Barrel Distortion by Helmut Dersch at http://www.all-in-one.ee/~dersch/barrel/barrel.html Quoting from this reference: How to determine suitable Parameters: The correcting function is a third order polynomial. It relates the distance of a pixel from the center of the source image (rsrc) to the corresponding distance in the corrected image (rdest) : rsrc = ( a * rdest3 + b * rdest2 + c * rdest + d ) * rdest The parameter d describes the linear scaling of the image. Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d-values scales the image by that amount. a,b and c distort the image. Using negative values shifts distant points away from the center. This counteracts barrel distortion, and is the basis for the above corrections. Using positive values shifts distant points towards the center. This counteracts pincussion distortions. Correcting using 'a' affects only the outermost pixels of the image, while 'b' correction is more uniform. Finally, you may correct pincussion and barrel distortions in the same image: If the outer regions exhibit barrel distortions, and the inner parts pincussion, you should use negative 'a' and positive 'b' values. If you do not want to scale the image, you should set d so that a +b + c + d = 1. In most cases, you will get quite satisfactory results by using just one parameter, like the 'b'-parameter in the above examples. These examples may also serve as a guide to how large these values should be, ie around 0.1 if the distortion is quite visible, or around 0.01 if it is very small. Simply optimize this starting value until you like your image. Reference 2.) Lens correction model by From PanoTools.org Wiki at http://wiki.panotools.org/Lens_correction_model Quoting from this reference: Usual values for a, b, and c are below 1.0, in most cases below 0.01. The a and c parameters control more complex forms of distortion. In most cases it will be enough to optimize for the b parameter only, which is good at correcting normal barrel distortion and pincushion distortion.
-
-
Field Summary
Fields Modifier and Type Field Description private float
a
DOCUMENT ME!private float
b
DOCUMENT ME!private float
c
private float
d
-
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 AlgorithmBarrelDistortion()
AlgorithmBarrelDistortion - default constructor.AlgorithmBarrelDistortion(ModelImage destImg, ModelImage srcImg, float a, float b, float c, float d)
AlgorithmBarrelDistortion.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finalize()
finalize -void
runAlgorithm()
Starts the program.-
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
-
-
-
-
Constructor Detail
-
AlgorithmBarrelDistortion
public AlgorithmBarrelDistortion()
AlgorithmBarrelDistortion - default constructor.
-
AlgorithmBarrelDistortion
public AlgorithmBarrelDistortion(ModelImage destImg, ModelImage srcImg, float a, float b, float c, float d)
AlgorithmBarrelDistortion.- Parameters:
destImg
- DOCUMENT ME!srcImg
- DOCUMENT ME!a
-b
-c
-d
-
-
-
Method Detail
-
finalize
public void finalize()
finalize -- Overrides:
finalize
in classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
Starts the program.- Specified by:
runAlgorithm
in classAlgorithmBase
-
-