Class 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 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 to
        kImageB - image that is changing to match to imageA
        doOrigins - flag for turning on/off using the image origins to match the images
        doOrients - 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 to
        kImageB - image that is changing to match to imageA
        doOrigins - flag for turning on/off using the image origins to match the images
        doOrients - 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 class AlgorithmBase
      • 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 value
        green - green pad value
        blue - blue pad value
      • runAlgorithm

        public void runAlgorithm()
        Description copied from class: AlgorithmBase
        Actually runs the algorithm. Implemented by inheriting algorithms.
        Specified by:
        runAlgorithm in class AlgorithmBase
      • 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.