Class AlgorithmMatchImages
java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.utilities.AlgorithmMatchImages
- All Implemented Interfaces:
ActionListener,WindowListener,Runnable,EventListener
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanflag for turning on/off using the image orientations to match the imagesprivate booleanflag for turning on/off using the image origins to match the imagesprivate float[]image values to use for padding the images, if necessaryprivate ModelImagesrcImageB: image to match to srcImageprivate booleanWhen 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, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmMatchImages(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
Modifier and TypeMethodDescriptionprivate ModelImagechangeResolutions(ModelImage kImage, float[] afNewRes) Changes the resolutions of the input image.voidremove local memoryvoidfinalize()Prepares this class for destruction.Returns imageA, which may have changed during the match.Returns imageB, which may have changed during the match.private booleanmatchOriginsExtents(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 voidmatchUnits(ModelImage imageA, ModelImage imageB) Matches the units of measure for the two input images.private ModelImagepadImage(ModelImage kImage, int[] padFront, int[] padBack) Adds or removes margins to the input image.voidActually runs the algorithm.voidsetPadValue(float value) Sets the pad value for single-channel images.voidsetPadValue(float red, float green, float blue) Sets the pad value for color imagesMethods 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, windowOpenedMethods 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
srcImageB
srcImageB: image to match to srcImage -
doOrigins
private boolean doOriginsflag for turning on/off using the image origins to match the images -
doOrients
private boolean doOrientsflag for turning on/off using the image orientations to match the images -
useReferenceResolutions
private boolean useReferenceResolutionsWhen true resolution matching defaults to the reference image. -
padValue
private float[] padValueimage values to use for padding the images, if necessary
-
-
Constructor Details
-
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 Details
-
disposeLocal
public void disposeLocal()remove local memory -
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
getImageA
Returns imageA, which may have changed during the match.- Returns:
- imageA
-
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:AlgorithmBaseActually runs the algorithm. Implemented by inheriting algorithms.- Specified by:
runAlgorithmin classAlgorithmBase
-
matchUnits
Matches the units of measure for the two input images.- Parameters:
imageA- target image to match to.imageB- image that is being changed.
-
matchResolutions
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
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
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.
-