Exemplo n.º 1
0
 /// <summary>
 /// Split color channels of a rgb image and return a list with channels as sitk.Image.
 /// list[0] = red channel
 /// list[1] = blue channel
 /// list[2] = green channel
 /// </summary>
 /// <param name="img">color image (rgb)</param>
 /// <returns>list with three color channels</returns>
 public static List <sitk.Image> SplitColorChannels(sitk.Image img)
 {
     if (img.GetNumberOfComponentsPerPixel() >= 3)
     {
         List <sitk.Image> result = new List <sitk.Image>();
         sitk.VectorIndexSelectionCastImageFilter rgbVector = new sitk.VectorIndexSelectionCastImageFilter();
         result.Add(rgbVector.Execute(img, 0, sitk.PixelIDValueEnum.sitkFloat32));
         result.Add(rgbVector.Execute(img, 1, sitk.PixelIDValueEnum.sitkFloat32));
         result.Add(rgbVector.Execute(img, 2, sitk.PixelIDValueEnum.sitkFloat32));
         return(result);
     }
     else
     {
         return(null);
     }
 }