1 #include "itkImage.h"
2 #include "itkImageFileReader.h"
3 //为了使用 itk::RGBPixel 类,包含头文件
4 #include "itkRGBPixel.h"
5 //在 ITK 中如何表示 RGB 图像。
6 int main( int , char * argv[] )
7 };
25
26 //使用 RGBPixel 类提供的方法来执行对像素色彩成分的访问
27 PixelType onePixel = image>GetPixel( pixelIndex );
28 PixelType::ValueType red = onePixel.GetRed();//提取红色部分
29 PixelType::ValueType green = onePixel.GetGreen();//提取绿色部分
30 PixelType::ValueType blue = onePixel.GetBlue();//提取蓝色部分
31 // Software Guide : EndCodeSnippet
32 std::cout << "method1" << std::endl;
33 std::cout << "Pixel values fr GetRed,GetGreen,GetBlue:" << std::endl;
34 std::cout << "Red = "
35 << itk::NumericTraits<PixelType::ValueType>::PrintType(red)
36 << std::endl;
37 std::cout << "Green = "
38 << itk::NumericTraits<PixelType::ValueType>::PrintType(green)
39 << std::endl;
40 std::cout << "Blue = "
41 << itk::NumericTraits<PixelType::ValueType>::PrintType(blue)
42 << std::endl << std::endl;
43
44
45 //由于 itk::RGBPixel 从 itk::FixedArray 类继承了 [ ] 操作
46 //以下方法也可执行对像素色彩成分的访问
47 red = onePixel[0]; // extract Red cponent
48 green = onePixel[1]; // extract Green cponent
49 blue = onePixel[2]; // extract Blue cponent
50
51 std::cout << "method2" << std::endl;
52 std::cout << "Pixel values:" << std::endl;
53 std::cout << "Red = "
54 << itk::NumericTraits<PixelType::ValueType>::PrintType(red)
55 << std::endl;
56 std::cout << "Green = "
57 << itk::NumericTraits<PixelType::ValueType>::PrintType(green)
58 << std::endl;
59 std::cout << "Blue = "
60 << itk::NumericTraits<PixelType::ValueType>::PrintType(blue)
61 << std::endl;
62 return EXIT_SUCCESS;
}
上一篇:VTK 实例56:网格抽取(多分辨率处理)
下一篇:VTK 实例65:最大密度投影法体绘制
ITK









