Class AlgorithmMatchImages
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.utilities.AlgorithmMatchImages
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmMatchImages extends AlgorithmBase
Matches two ModelImages. The output of this Algorithm is two ModelImages that have the same units of measure, the same resolutions, and the same extents. If the user chooses, the image orientations (left-to-right, anterior-to-posterior, inferior-to-superior, etc) will be matched. If the user chooses, the image origins will be matched. Either imageA, imageB or sometimes neither will be different after the algorithm completes. The result images are returned with the getImageA() and getImageB() functions.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
doOrients
flag for turning on/off using the image orientations to match the imagesprivate boolean
doOrigins
flag for turning on/off using the image origins to match the imagesprivate float[]
padValue
image values to use for padding the images, if necessaryprivate ModelImage
srcImageB
srcImageB: image to match to srcImageprivate boolean
useReferenceResolutions
When true resolution matching defaults to the reference image.-
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 AlgorithmMatchImages(ModelImage kImageA, ModelImage kImageB, boolean doOrigins, boolean doOrients)
Create an AlgorithmMatchImages to match the two input images.AlgorithmMatchImages(ModelImage kImageA, ModelImage kImageB, boolean doOrigins, boolean doOrients, boolean useReferenceResolutions)
Create an AlgorithmMatchImages to match the two input images.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ModelImage
changeResolutions(ModelImage kImage, float[] afNewRes)
Changes the resolutions of the input image.void
disposeLocal()
remove local memoryvoid
finalize()
Prepares this class for destruction.ModelImage
getImageA()
Returns imageA, which may have changed during the match.ModelImage
getImageB()
Returns imageB, which may have changed during the match.private boolean
matchOriginsExtents(ModelImage imageA, ModelImage imageB, int[] padAFront, int[] padABack, int[] padBFront, int[] padBBack)
Matches the origins and extents of the two input images.private float[]
matchResolutions(ModelImage imageA, ModelImage imageB)
Match the resolutions of the two images.private void
matchUnits(ModelImage imageA, ModelImage imageB)
Matches the units of measure for the two input images.private ModelImage
padImage(ModelImage kImage, int[] padFront, int[] padBack)
Adds or removes margins to the input image.void
runAlgorithm()
Actually runs the algorithm.void
setPadValue(float value)
Sets the pad value for single-channel images.void
setPadValue(float red, float green, float blue)
Sets the pad value for color images-
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
-
srcImageB
private ModelImage srcImageB
srcImageB: image to match to srcImage
-
doOrigins
private boolean doOrigins
flag for turning on/off using the image origins to match the images
-
doOrients
private boolean doOrients
flag for turning on/off using the image orientations to match the images
-
useReferenceResolutions
private boolean useReferenceResolutions
When true resolution matching defaults to the reference image.
-
padValue
private float[] padValue
image values to use for padding the images, if necessary
-
-
Constructor Detail
-
AlgorithmMatchImages
public AlgorithmMatchImages(ModelImage kImageA, ModelImage kImageB, boolean doOrigins, boolean doOrients)
Create an AlgorithmMatchImages to match the two input images.- Parameters:
kImageA
- target image to match tokImageB
- image that is changing to match to imageAdoOrigins
- flag for turning on/off using the image origins to match the imagesdoOrients
- flag for turning on/off using the image orientations to match the images
-
AlgorithmMatchImages
public AlgorithmMatchImages(ModelImage kImageA, ModelImage kImageB, boolean doOrigins, boolean doOrients, boolean useReferenceResolutions)
Create an AlgorithmMatchImages to match the two input images.- Parameters:
kImageA
- target image to match tokImageB
- image that is changing to match to imageAdoOrigins
- flag for turning on/off using the image origins to match the imagesdoOrients
- flag for turning on/off using the image orientations to match the images
-
-
Method Detail
-
disposeLocal
public void disposeLocal()
remove local memory
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
getImageA
public ModelImage getImageA()
Returns imageA, which may have changed during the match.- Returns:
- imageA
-
getImageB
public ModelImage getImageB()
Returns imageB, which may have changed during the match.- Returns:
- imageB
-
setPadValue
public void setPadValue(float value)
Sets the pad value for single-channel images.- Parameters:
value
- value used to pad images.
-
setPadValue
public void setPadValue(float red, float green, float blue)
Sets the pad value for color images- Parameters:
red
- red pad valuegreen
- green pad valueblue
- blue pad value
-
runAlgorithm
public void runAlgorithm()
Description copied from class:AlgorithmBase
Actually runs the algorithm. Implemented by inheriting algorithms.- Specified by:
runAlgorithm
in classAlgorithmBase
-
matchUnits
private void matchUnits(ModelImage imageA, ModelImage imageB)
Matches the units of measure for the two input images.- Parameters:
imageA
- target image to match to.imageB
- image that is being changed.
-
matchResolutions
private float[] matchResolutions(ModelImage imageA, ModelImage imageB)
Match the resolutions of the two images. Determines the lowest resolution of either image along each dimension. If useReferenceResolutions is true, the reference image (imageA) resolutions are used.- Parameters:
imageA
-imageB
-- Returns:
- new resolutions that will be applied to both images.
-
changeResolutions
private ModelImage changeResolutions(ModelImage kImage, float[] afNewRes)
Changes the resolutions of the input image.- Parameters:
kImage
- input image.afNewRes
- new resolutions.- Returns:
- new ModelImage, or the input image if unchanged.
-
matchOriginsExtents
private boolean matchOriginsExtents(ModelImage imageA, ModelImage imageB, int[] padAFront, int[] padABack, int[] padBFront, int[] padBBack)
Matches the origins and extents of the two input images. Matching origins is an option the user sets.- Parameters:
imageA
- input image A.imageB
- input image B.padAFront
- output values for adding or removing voxels to the front of imageA [left,top,front,time]padABack
- output values for adding or removing voxels to the back of imageA [right,bottom,back,time]padBFront
- output values for adding or removing voxels to the front of imageB [left,top,front,time]padBBack
- output values for adding or removing voxels to the back of imageB [right,bottom,back,time]- Returns:
- true if either image requires changing to match the two images, false if neither image requires changing.
-
padImage
private ModelImage padImage(ModelImage kImage, int[] padFront, int[] padBack)
Adds or removes margins to the input image.- Parameters:
kImage
- input images.padFront
- margins to add or remove to the front of the image [left,top,front,time]padBack
- margins to add or remove to the end of the image [right,bottom,back,time]- Returns:
- new image or the original input image if no change.
-
-