Package gov.nih.mipav.model.algorithms
Class AlgorithmPrincipalComponents
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmPrincipalComponents
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.FocusListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmPrincipalComponents extends AlgorithmBase implements java.awt.event.ActionListener, java.awt.event.FocusListener
This algorithm operates on 3D black and white images and on 2D and 3D color images. The user can select 1 or both of 2 output images: The first image is a filtered 3D image containing only the first n principal components, where n is selected by the user after viewing images of the first 10 (or the number that exist if less than 10) principal components. The second image is a 2D image created by averaging together the images in the 3D image. Note that red, green, and blue are treated as separate 2D planes. This implementation assumes that the noise variance is equal in every slice and that the noise is uncorrelated between slices. Principal components maximizes data variance in components; it concentrates the information content of the data in as small a number of components as possible. This algorithm is based on: 1.) Digital Image Processing, Third Edition by Rafael C. Gonzalez and Richard E. Woods, Section 11.4 Use of Principal Components for Description, pp. 842 - 852, 2008 by Pearson Education, Inc. Information about using a matchImage: Eigenfaces for Recognition by Matthew Turk and Alex Pentland Vision and Modeling Group The Media Laboratory Massachusetts Institute of Technology 2.) Gabor Feature Based Classification Using the Enhanced Linear Discriminant Model for Face Recognition by Chengjun Liu and Harry Wechsler states "For the Eigenfaces method, the Mahalanobis distance measure performs better than the L1 distance measure, followed in order by the L2 distance measure and the cosine similarity measure as shown in Fig. 6. The Mahalanobis distance measure performs better than the other similarity measures because the Mahalanobis distance measure counteracts the fact that the L1 and L2 distance measures in PCA space weight preferentially for low frequencies, and this is consistent with results reported by Moghaddam and Pentland and Sung and Poggio. As the L2 measure weights more the low frequencies than L1 does, the L1 distance measure should perform better than the L2 distance measure, a conjecture validated by our experiments as shown in Figure 6. The cosine similarity measure does not compensate the low frequency preference, and it performs worst among all the measures." 3.) "The statistical properties of three noise removal procedures for multichannel remotely sensed data" by M. Berman, CSIRO Division of Mathemetics and Statistics P.O. Box 218, Lindfield, N.S.W., 2070 Consulting Report NSW/85/31/MB9 Note that this algorithm has 4 different names: Hotelling, eigenvector, principal component, and Karhunen-Loeve transform. Also note that when the noise variance is the same in all bands and the noise is uncorrelated between bands the principal component transformation is equivalent to the maximum noise fraction transformation. In the more general case, the MNF transform is equivalent to a transformation of the data to a coordinate system in which the noise covariance matrix is the identity matrix, followed by a principal components transformation. The transform in this form is the noise-adjusted principal components transform. In forward order MNF maximizes the noise content in successive components that are uncorrelated over the dataset or equivalently in reverse order MNF maximizes the signal to noise ratio of each component. Information about the signal to noise ratio improvement is found in "Information Extraction, SNR Improvement, and Data Compression in MultiSpectral Imagery", Patrick J. Ready and Paul A. Wintz, IEEE Transactions on Communications, Vol. COM-21, No. 10, October, 1973, pp. 1123-1130.
-
-
Field Summary
Fields Modifier and Type Field Description private ModelImage[]
destImage
DOCUMENT ME!private boolean
displayAndAsk
DOCUMENT ME!private boolean
doAveraging
if true create an image averaging together the slices in the filtered version.private boolean
doFilter
if true create a filtered version of the original image.private boolean
doMahalanobisDistance
private boolean
haveColor
DOCUMENT ME!private ModelImage
matchImage
If this 2D black and white image is present, it is matched to the closest slice and/or color in the source image model by looking for the closest match of the weights of the principal components.private int
nPlanes
number of image planes present.private int
nPresent
number of principal components displayed 10 or less than 10 if fewer exist.private javax.swing.JButton
OKButton
DOCUMENT ME!private int
pNumber
number of principal components to be retained.private javax.swing.JDialog
pNumberDialog
DOCUMENT ME!private boolean
pressedOK
DOCUMENT ME!private boolean
principalComponentsOnly
private ModelImage
srcImage
DOCUMENT ME!private javax.swing.JTextField
textNumber
DOCUMENT ME!-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, threadStopped
-
-
Constructor Summary
Constructors Constructor Description AlgorithmPrincipalComponents(ModelImage[] destImg, ModelImage srcImg, boolean doFilter, boolean doAveraging, boolean displayAndAsk, int pNumber)
Creates a new AlgorithmPrincipalComponents object.AlgorithmPrincipalComponents(ModelImage[] destImg, ModelImage srcImg, int pNumber)
Creates a new AlgorithmPrincipalComponents object.AlgorithmPrincipalComponents(ModelImage[] destImg, ModelImage srcImg, ModelImage matchImage, boolean doFilter, boolean doAveraging, boolean displayAndAsk, int pNumber, boolean doMahalanobisDistance)
Creates a new AlgorithmPrincipalComponents object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent event)
Calls various methods depending on the action.private void
createPNumberDialog(java.awt.event.ActionListener al)
DOCUMENT ME!void
finalize()
Prepares this class for destruction.void
focusGained(java.awt.event.FocusEvent event)
Do nothing.void
focusLost(java.awt.event.FocusEvent event)
Do nothing.private void
pComponent()
DOCUMENT ME!void
runAlgorithm()
Start algorithm.void
updateFileInfo(ModelImage image, ModelImage resultImage)
Copy important file information to resultant image structure.-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
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
-
destImage
private ModelImage[] destImage
DOCUMENT ME!
-
displayAndAsk
private boolean displayAndAsk
DOCUMENT ME!
-
doAveraging
private boolean doAveraging
if true create an image averaging together the slices in the filtered version.
-
doFilter
private boolean doFilter
if true create a filtered version of the original image.
-
haveColor
private boolean haveColor
DOCUMENT ME!
-
principalComponentsOnly
private boolean principalComponentsOnly
-
nPlanes
private int nPlanes
number of image planes present.
-
nPresent
private int nPresent
number of principal components displayed 10 or less than 10 if fewer exist.
-
OKButton
private javax.swing.JButton OKButton
DOCUMENT ME!
-
pNumber
private int pNumber
number of principal components to be retained.
-
pNumberDialog
private javax.swing.JDialog pNumberDialog
DOCUMENT ME!
-
pressedOK
private boolean pressedOK
DOCUMENT ME!
-
srcImage
private ModelImage srcImage
DOCUMENT ME!
-
textNumber
private javax.swing.JTextField textNumber
DOCUMENT ME!
-
matchImage
private ModelImage matchImage
If this 2D black and white image is present, it is matched to the closest slice and/or color in the source image model by looking for the closest match of the weights of the principal components.
-
doMahalanobisDistance
private boolean doMahalanobisDistance
-
-
Constructor Detail
-
AlgorithmPrincipalComponents
public AlgorithmPrincipalComponents(ModelImage[] destImg, ModelImage srcImg, ModelImage matchImage, boolean doFilter, boolean doAveraging, boolean displayAndAsk, int pNumber, boolean doMahalanobisDistance)
Creates a new AlgorithmPrincipalComponents object.- Parameters:
destImg
- image model where result image is to storedsrcImg
- source image modelmatchImage
- match image match this image to the closest slice and/or color in the source imagedoFilter
- if true create a filtered version of the original imagedoAveraging
- if true create an image averaging together the slices in the filtered versiondisplayAndAsk
- if true display principal component images and ask how many to retainpNumber
- if displayAndAsk if false pNumber is the number of principal component images to retaindoMahalanobisDistance
- Select Euclidean or Mahalanobis distance for matching
-
AlgorithmPrincipalComponents
public AlgorithmPrincipalComponents(ModelImage[] destImg, ModelImage srcImg, boolean doFilter, boolean doAveraging, boolean displayAndAsk, int pNumber)
Creates a new AlgorithmPrincipalComponents object.- Parameters:
destImg
- image model where result image is to storedsrcImg
- source image modeldoFilter
- if true create a filtered version of the original imagedoAveraging
- if true create an image averaging together the slices in the filtered versiondisplayAndAsk
- if true display principal component images and ask how many to retainpNumber
- if displayAndAsk if false pNumber is the number of principal component images to retain
-
AlgorithmPrincipalComponents
public AlgorithmPrincipalComponents(ModelImage[] destImg, ModelImage srcImg, int pNumber)
Creates a new AlgorithmPrincipalComponents object. Option only returns principal components- Parameters:
destImg
- image model where result image is to storedsrcImg
- source image modeldoFilter
- if true create a filtered version of the original imagedoAveraging
- if true create an image averaging together the slices in the filtered versiondisplayAndAsk
- if true display principal component images and ask how many to retainpNumber
- if displayAndAsk if false pNumber is the number of principal component images to retain
-
-
Method Detail
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent event)
Calls various methods depending on the action.- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
- Overrides:
actionPerformed
in classAlgorithmBase
- Parameters:
event
- event that triggered function
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
focusGained
public void focusGained(java.awt.event.FocusEvent event)
Do nothing.- Specified by:
focusGained
in interfacejava.awt.event.FocusListener
- Parameters:
event
- Focus event
-
focusLost
public void focusLost(java.awt.event.FocusEvent event)
Do nothing.- Specified by:
focusLost
in interfacejava.awt.event.FocusListener
- Parameters:
event
- Focus event
-
runAlgorithm
public void runAlgorithm()
Start algorithm.- Specified by:
runAlgorithm
in classAlgorithmBase
-
updateFileInfo
public void updateFileInfo(ModelImage image, ModelImage resultImage)
Copy important file information to resultant image structure.- Parameters:
image
- Source image.resultImage
- Resultant image.
-
createPNumberDialog
private void createPNumberDialog(java.awt.event.ActionListener al)
DOCUMENT ME!- Parameters:
al
- DOCUMENT ME!
-
pComponent
private void pComponent()
DOCUMENT ME!
-
-