/// <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); }