Package gov.nih.mipav.model.algorithms
Class AlgorithmMaximumLikelihoodIteratedBlindDeconvolution
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmMaximumLikelihoodIteratedBlindDeconvolution
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmMaximumLikelihoodIteratedBlindDeconvolution extends AlgorithmBase
An implementation of Maximum Likelihood Iterated Blind Deconvolution based on the following papers:Holmes, T.J., Maximum Likelihood Image Restoration Adapted for Noncoherent Optical Imaging, JOSA-A, 5(5): 666-673, 1988.
Holmes, T., Bhattacharyya, S., Cooper, J., Hanzel, D., Krishnamurthi, V., Lin, W., Roysam, B., Szarowski, D., Turner, J., Light Microscopic Images Reconstructed by Maximum Likelihood Deconvolution, Ch. 24, Handbook of Biological Confocal Microscopy, J. Pawley, Plenum, 1995.
Holmes, T., Liu, Y., Image Restoration for 2D and 3D Fluorescence Microscopy, Visualization in Biomedical Microscopies, A. Kriete, VCH, 1992.
Holmes, T., Blind Deconvolution of Quantum-Limited Noncoherent Imagery, JOSA-A, 9: 1052 - 1061, 1992.
-
-
Field Summary
Fields Modifier and Type Field Description private float[]
m_afResolutions
DOCUMENT ME!private int[]
m_aiUnits
DOCUMENT ME!private boolean
m_bConstraintsInit
DOCUMENT ME!private boolean
m_bUpdatePBar
Flag indicating whether or not to update the progres bar:.private boolean
m_bUseMicroscopeConstraints
Boolean to use constraints:.private float
m_fAxialBandLimit
DOCUMENT ME!private float[]
m_fNewRes
The new resolutions in each dimension if resample is true.private float
m_fObjectiveNumericalAperature
numerical aperature of the imaging lens:.private float
m_fRadialBandLimit
3).private float
m_fRadius
DOCUMENT ME!private float
m_fRefractiveIndex
sample index of refraction:.private float
m_fTanTheta
DOCUMENT ME!private float
m_fWavelength
wavelength of the reflected or fluorescing light:.private int
m_iArrayLength
Original data size:.private int
m_iDimX
Constraint parameters:.private int
m_iDimY
DOCUMENT ME!private int
m_iDimZ
DOCUMENT ME!private int
m_iNumberIterations
Number of iterations for the deconvolution:.private int
m_iNumberProgress
Show the deconvolved image in progress every m_iNumberProgress steps:.private ModelImage
m_kCalcResult1
DOCUMENT ME!private ModelImage
m_kCalcResult2
DOCUMENT ME!private ModelImage
m_kCalcResult3
DOCUMENT ME!private ModelImage
m_kEstimatedImage
estimated of the reconstructed image:.private ModelImage
m_kImageSpectrum1
Images to store FFT and Calc results.private ModelImage
m_kImageSpectrum2
DOCUMENT ME!private ModelImage
m_kImageSpectrum3
DOCUMENT ME!private ModelImage
m_kMirrorImage
DOCUMENT ME!private ModelImage
m_kOriginalSourceImage
source image to be reconstructed!private ModelImage
m_kPSFImage
point spread function image:.private ModelImage
m_kPSFImageCopy
Used for color image.private ModelImage
m_kSourceBlue
DOCUMENT ME!private ModelImage
m_kSourceGreen
DOCUMENT ME!private ModelImage
m_kSourceImage
source image to be reconstructed!private ModelImage
m_kSourceRed
For color images: the source is converted to gray for the deconvolution.-
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 AlgorithmMaximumLikelihoodIteratedBlindDeconvolution(ModelImage kSrcImg, int iIterations, int iProgress, float fObjectiveNumericalAperature, float fWavelength, float fRefractiveIndex, boolean bUseConstraints, int[] newExtents, boolean doResample)
Creates a new AlgorithmMaximumLikelihoodIteratedBlindDeconvolution object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ModelImage
calc(ModelImage kReturn, ModelImage kImage1, ModelImage kImage2, int iType)
Performs a AlgorithmImageCalculator calculation on the two input images.private void
cleanUp()
Dispose of temporary images after the deconvolution process is completed:private ModelImage
constraints(ModelImage kImagePSF)
Applies constraints to the input image kImage and writes the constrained values into the m_kPSFImage.private ModelImage
convertFromGray(ModelImage kRed, ModelImage kGreen, ModelImage kBlue)
Called after the deconvolution algorithm is run.private ModelImage
convertToGray(ModelImage kImage)
Convert the input image, kImage, to a grayscale image using the AlgorithmRGBtoGray.private ModelImage
convolve(ModelImage kImage1, ModelImage kImage2, float fNoise)
Convolves two image by computing the fast fourier transforms of each image, multiplying the ffts and then computing the inverse fft of the result:void
disposeLocal()
Dispose of local variables that may be taking up lots of room.private ModelImage
fft(ModelImage kImageFFT, ModelImage kImage, int iDir)
Computes the fft of the input image, returns the fft.void
finalize()
Prepares this class for destruction.ModelImage
getPSFImage()
Returns the point spread function image.ModelImage
getReconstructedImage()
Returns the reconstructed image:private void
initConstraints()
Initializes the constraint variables for the PSF deconvolution, based on the microscope parameters (numerical aperature, wavelength, and refractive index).private void
initPSF(int iNumberDimensions, int[] aiExtents)
Initialize the first PSF guess as a 3x3 Gaussian.private ModelImage
mirror(ModelImage kImage)
Does a mirror operation on an image, so that x, y, and z values are mirrored Calls JDialogFlip.private ModelImage
resample(ModelImage kImage, int[] newExtents)
void
runAlgorithm()
Starts the program.private ModelImage
runDeconvolution(ModelImage kSource, ModelImage kEstimate, ModelImage kPSF, boolean bCopy)
Runs the deconvolution algorithm.-
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
-
m_afResolutions
private float[] m_afResolutions
DOCUMENT ME!
-
m_aiUnits
private int[] m_aiUnits
DOCUMENT ME!
-
m_bConstraintsInit
private boolean m_bConstraintsInit
DOCUMENT ME!
-
m_bUpdatePBar
private boolean m_bUpdatePBar
Flag indicating whether or not to update the progres bar:.
-
m_bUseMicroscopeConstraints
private boolean m_bUseMicroscopeConstraints
Boolean to use constraints:.
-
m_fAxialBandLimit
private float m_fAxialBandLimit
DOCUMENT ME!
-
m_fObjectiveNumericalAperature
private float m_fObjectiveNumericalAperature
numerical aperature of the imaging lens:.
-
m_fRadialBandLimit
private float m_fRadialBandLimit
3). Bandlimit and missing cone constraint:
-
m_fRadius
private float m_fRadius
DOCUMENT ME!
-
m_fRefractiveIndex
private float m_fRefractiveIndex
sample index of refraction:.
-
m_fTanTheta
private float m_fTanTheta
DOCUMENT ME!
-
m_fWavelength
private float m_fWavelength
wavelength of the reflected or fluorescing light:.
-
m_iArrayLength
private int m_iArrayLength
Original data size:.
-
m_iDimX
private int m_iDimX
Constraint parameters:.
-
m_iDimY
private int m_iDimY
DOCUMENT ME!
-
m_iDimZ
private int m_iDimZ
DOCUMENT ME!
-
m_iNumberIterations
private int m_iNumberIterations
Number of iterations for the deconvolution:.
-
m_iNumberProgress
private int m_iNumberProgress
Show the deconvolved image in progress every m_iNumberProgress steps:.
-
m_fNewRes
private float[] m_fNewRes
The new resolutions in each dimension if resample is true. Used only if resample is true.
-
m_kCalcResult1
private ModelImage m_kCalcResult1
DOCUMENT ME!
-
m_kCalcResult2
private ModelImage m_kCalcResult2
DOCUMENT ME!
-
m_kCalcResult3
private ModelImage m_kCalcResult3
DOCUMENT ME!
-
m_kEstimatedImage
private ModelImage m_kEstimatedImage
estimated of the reconstructed image:.
-
m_kImageSpectrum1
private ModelImage m_kImageSpectrum1
Images to store FFT and Calc results.
-
m_kImageSpectrum2
private ModelImage m_kImageSpectrum2
DOCUMENT ME!
-
m_kImageSpectrum3
private ModelImage m_kImageSpectrum3
DOCUMENT ME!
-
m_kMirrorImage
private ModelImage m_kMirrorImage
DOCUMENT ME!
-
m_kOriginalSourceImage
private ModelImage m_kOriginalSourceImage
source image to be reconstructed!
-
m_kPSFImage
private ModelImage m_kPSFImage
point spread function image:.
-
m_kPSFImageCopy
private ModelImage m_kPSFImageCopy
Used for color image.
-
m_kSourceBlue
private ModelImage m_kSourceBlue
DOCUMENT ME!
-
m_kSourceGreen
private ModelImage m_kSourceGreen
DOCUMENT ME!
-
m_kSourceImage
private ModelImage m_kSourceImage
source image to be reconstructed!
-
m_kSourceRed
private ModelImage m_kSourceRed
For color images: the source is converted to gray for the deconvolution. Once the estimate and psf are found, each component is reconstructed.
-
-
Constructor Detail
-
AlgorithmMaximumLikelihoodIteratedBlindDeconvolution
public AlgorithmMaximumLikelihoodIteratedBlindDeconvolution(ModelImage kSrcImg, int iIterations, int iProgress, float fObjectiveNumericalAperature, float fWavelength, float fRefractiveIndex, boolean bUseConstraints, int[] newExtents, boolean doResample)
Creates a new AlgorithmMaximumLikelihoodIteratedBlindDeconvolution object.- Parameters:
kSrcImg
- the input image to be reconstructediIterations
- the number of times to iterate in the deconvolutioniProgress
- Display deconvolved image every iProgress imagesfObjectiveNumericalAperature
- the numerical aperature of the imaging lensefWavelength
- the reflected or fluorescing lightfRefractiveIndex
- the index of refraction for the samplebUseConstraints
- When true, the lens NA, wavelength, and refractive index are used in the deconvolution process
-
-
Method Detail
-
disposeLocal
public void disposeLocal()
Dispose of local variables that may be taking up lots of room.
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
getPSFImage
public ModelImage getPSFImage()
Returns the point spread function image.- Returns:
- m_kPSFImage
-
getReconstructedImage
public ModelImage getReconstructedImage()
Returns the reconstructed image:- Returns:
- m_kEstimatedImage
-
runAlgorithm
public void runAlgorithm()
Starts the program.- Specified by:
runAlgorithm
in classAlgorithmBase
-
calc
private ModelImage calc(ModelImage kReturn, ModelImage kImage1, ModelImage kImage2, int iType)
Performs a AlgorithmImageCalculator calculation on the two input images. Used here to either multiply or divide two images.- Parameters:
kReturn
- DOCUMENT ME!kImage1
- the first input imagekImage2
- the second input imageiType
- the type of calculation (multiply or divide)- Returns:
- kReturn, the result of the image calculation
-
cleanUp
private void cleanUp()
Dispose of temporary images after the deconvolution process is completed:
-
constraints
private ModelImage constraints(ModelImage kImagePSF)
Applies constraints to the input image kImage and writes the constrained values into the m_kPSFImage. Constraints are the following: 2). Hourglass constraint 3). Bandlimit and missing cone constraint 4). Nonnegativity constraint 1). Unit summation constraint- Parameters:
kImagePSF
- the unconstrained PSFImage- Returns:
- DOCUMENT ME!
-
convertFromGray
private ModelImage convertFromGray(ModelImage kRed, ModelImage kGreen, ModelImage kBlue)
Called after the deconvolution algorithm is run. The deconvolution processes the grayscale image. Once the estimated and psf images are calculated, they are used to reconstruct the red, green, and blue channels separately, which are then recombined into a color image.- Parameters:
kRed
- the reconstructed red imagekGreen
- the reconstructed green imagekBlue
- the reconstructed blue image- Returns:
- the RGB image
-
convertToGray
private ModelImage convertToGray(ModelImage kImage)
Convert the input image, kImage, to a grayscale image using the AlgorithmRGBtoGray. The deconvolution is done on the grayscale image, however after deconvolution, the original color values are reconstructed from the psf and grayscale estimate.- Parameters:
kImage
- the color image to conver to grayscale:- Returns:
- the converted grayscale image
-
convolve
private ModelImage convolve(ModelImage kImage1, ModelImage kImage2, float fNoise)
Convolves two image by computing the fast fourier transforms of each image, multiplying the ffts and then computing the inverse fft of the result:- Parameters:
kImage1
- the first input imagekImage2
- the second input imagefNoise
- amount of Noise to add when the result of the convolution is going to be the denominator in the next equation to avoid divide by zero errors.- Returns:
- kResult, the result of convolving the two images
-
fft
private ModelImage fft(ModelImage kImageFFT, ModelImage kImage, int iDir)
Computes the fft of the input image, returns the fft. Calls AlgorithmFFT.- Parameters:
kImageFFT
- DOCUMENT ME!kImage
- the input imageiDir
- forward fft when iDir = 1, inverse fft when iDir = -1- Returns:
- kResult, the fft of kImage
-
initConstraints
private void initConstraints()
Initializes the constraint variables for the PSF deconvolution, based on the microscope parameters (numerical aperature, wavelength, and refractive index). The pixel resolutions are also converted to nanometers -- the units for wavelength.
-
initPSF
private void initPSF(int iNumberDimensions, int[] aiExtents)
Initialize the first PSF guess as a 3x3 Gaussian.- Parameters:
iNumberDimensions
- iNumberDimensions, the dimensions of the dataaiExtents
- aiExtents, the ranges in each dimension
-
mirror
private ModelImage mirror(ModelImage kImage)
Does a mirror operation on an image, so that x, y, and z values are mirrored Calls JDialogFlip.- Parameters:
kImage
- the input image- Returns:
- DOCUMENT ME!
-
resample
private ModelImage resample(ModelImage kImage, int[] newExtents)
-
runDeconvolution
private ModelImage runDeconvolution(ModelImage kSource, ModelImage kEstimate, ModelImage kPSF, boolean bCopy)
Runs the deconvolution algorithm.- Parameters:
kSource
- the original image datakEstimate
- the initial estimated guess at the reconstructed imagekPSF
- the initial point spread function guessbCopy
- when true the new estimates after interating are copied back into the data members.- Returns:
- , the resulting estimated image
-
-