/// <summary>
        /// Resize image depending on a reference image.
        /// </summary>
        /// <param name="toResize">image</param>
        /// <param name="referenceImage">reference image</param>
        /// <returns>resampled image</returns>
        public static sitk.Image ResizeImage(sitk.Image toResize, sitk.Image referenceImage)
        {
            if (toResize.GetWidth() == referenceImage.GetWidth() && toResize.GetHeight() == referenceImage.GetHeight())
            {
                return(toResize);
            }

            uint width  = toResize.GetWidth() < referenceImage.GetWidth() ? referenceImage.GetWidth() : toResize.GetWidth();
            uint height = toResize.GetHeight() < referenceImage.GetHeight() ? referenceImage.GetHeight() : toResize.GetHeight();

            sitk.VectorUInt32 vec = new sitk.VectorUInt32();
            vec.Add(width);
            vec.Add(height);

            sitk.ResampleImageFilter resampleFilter = new sitk.ResampleImageFilter();
            resampleFilter.SetSize(vec);
            resampleFilter.SetOutputOrigin(toResize.GetOrigin());
            resampleFilter.SetOutputDirection(toResize.GetDirection());
            resampleFilter.SetOutputSpacing(toResize.GetSpacing());
            resampleFilter.SetOutputPixelType(referenceImage.GetPixelID());
            resampleFilter.SetDefaultPixelValue(255.0);
            sitk.Image resultImage = resampleFilter.Execute(toResize);

            return(resultImage);
        }
        /// <summary>
        /// Create a checkerboard image of two corresponding images.
        /// </summary>
        /// <param name="fImg01">image 1</param>
        /// <param name="fImg02">image 2</param>
        /// <param name="size">grid size of the checker boar</param>
        /// <returns>checker board image</returns>
        public static sitk.Image GetCheckerBoardV2(string fImg01, string fImg02, uint size = 0)
        {
            sitk.Image img01 = ReadWriteUtils.ReadITKImageFromFile(fImg01);
            sitk.Image img02 = ReadWriteUtils.ReadITKImageFromFile(fImg02);

            uint width  = img01.GetWidth() > img02.GetWidth() ? img01.GetWidth() : img02.GetWidth();
            uint height = img01.GetHeight() > img02.GetHeight() ? img01.GetHeight() : img02.GetHeight();

            sitk.Image reference   = ImageUtils.ResizeImage(img01, width, height);
            sitk.Image transformed = ImageUtils.ResizeImage(img02, width, height);

            sitk.CheckerBoardImageFilter checkerBoard = new sitk.CheckerBoardImageFilter();
            uint lx = size;
            uint ly = width / (height / size);

            if (size != 0)
            {
                sitk.VectorUInt32 vec = new sitk.VectorUInt32();
                vec.Add(ly);
                vec.Add(lx);
                checkerBoard.SetCheckerPattern(vec);
            }
            sitk.Image result = checkerBoard.Execute(reference, transformed);
            img01.Dispose();
            img02.Dispose();
            reference.Dispose();
            transformed.Dispose();
            return(result);
        }
        public static sitk.Image GetCheckerBoard(sitk.Image img01, sitk.Image img02, uint size = 0)
        {
            uint width  = img01.GetWidth() > img02.GetWidth() ? img01.GetWidth() : img02.GetWidth();
            uint height = img01.GetHeight() > img02.GetHeight() ? img01.GetHeight() : img02.GetHeight();

            //Console.WriteLine(string.Format("width: Img01 [{0}] - Img02 [{1}]", img01.GetWidth(), img02.GetWidth()));
            //Console.WriteLine(string.Format("height: Img01 [{0}] - Img02 [{1}]", img01.GetHeight(), img02.GetHeight()));
            //Console.WriteLine(string.Format("pixel type: Img01 [{0}] - Img02 [{1}]", img01.GetPixelIDTypeAsString(), img02.GetPixelIDTypeAsString()));

            sitk.Image reference   = ImageUtils.ResizeImage(img01, width, height, sitk.PixelIDValueEnum.sitkFloat32);
            sitk.Image transformed = ImageUtils.ResizeImage(img02, width, height, sitk.PixelIDValueEnum.sitkFloat32);

            sitk.CheckerBoardImageFilter checkerBoard = new sitk.CheckerBoardImageFilter();

            if (size != 0)
            {
                sitk.VectorUInt32 vec = new sitk.VectorUInt32();
                vec.Add(size);
                vec.Add(size);
                checkerBoard.SetCheckerPattern(vec);
            }

            sitk.Image           temp            = checkerBoard.Execute(reference, transformed);
            sitk.CastImageFilter castImageFilter = new sitk.CastImageFilter();
            castImageFilter.SetOutputPixelType(sitk.PixelIDValueEnum.sitkUInt8);
            sitk.Image result = castImageFilter.Execute(temp);
            temp.Dispose();
            return(result);
        }
        /// <summary>
        /// Resize image by width and height and set output pixel type.
        /// </summary>
        /// <param name="img">input image</param>
        /// <param name="width">width</param>
        /// <param name="height">height</param>
        /// <param name="pixelType">output pixel type</param>
        /// <returns>resampled image</returns>
        public static sitk.Image ResizeImage(sitk.Image img, uint width, uint height, sitk.PixelIDValueEnum pixelType)
        {
            sitk.VectorUInt32 vec = new sitk.VectorUInt32();
            vec.Add(width);
            vec.Add(height);

            sitk.ResampleImageFilter resampleFilter = new sitk.ResampleImageFilter();
            resampleFilter.SetSize(vec);
            resampleFilter.SetOutputOrigin(img.GetOrigin());
            resampleFilter.SetOutputDirection(img.GetDirection());
            resampleFilter.SetOutputSpacing(img.GetSpacing());
            resampleFilter.SetOutputPixelType(pixelType);
            resampleFilter.SetDefaultPixelValue(255.0);
            sitk.Image resultImage = resampleFilter.Execute(img);
            img.Dispose();

            return(resultImage);
        }
        /// <summary>
        /// Resize image by new width and height.
        /// </summary>
        /// <param name="image">input image</param>
        /// <param name="newWidth">width</param>
        /// <param name="newHeight">height</param>
        /// <returns>resized image</returns>
        public static sitk.Image ResizeImage(sitk.Image image, uint newWidth, uint newHeight)
        {
            if (image.GetWidth() == newWidth && image.GetHeight() == newHeight)
            {
                return(image);
            }

            sitk.VectorUInt32 vec = new sitk.VectorUInt32();
            vec.Add(newWidth);
            vec.Add(newHeight);

            sitk.ResampleImageFilter resampleFilter = new sitk.ResampleImageFilter();
            resampleFilter.SetSize(vec);
            resampleFilter.SetOutputOrigin(image.GetOrigin());
            resampleFilter.SetOutputDirection(image.GetDirection());
            resampleFilter.SetOutputSpacing(image.GetSpacing());
            resampleFilter.SetOutputPixelType(image.GetPixelID());
            resampleFilter.SetDefaultPixelValue(255.0);
            sitk.Image resultImage = resampleFilter.Execute(image);

            return(resultImage);
        }