1 #include "itkVector.h"//向量类的头文件
2 #include "itkImage.h"
3
4 int main(int, char *[])
5 }; //First index at
15 const ImageType::SizeType size = }; //Size of
16
17 ImageType::RegionType region;
18 region.SetSize( size );
19 region.SetIndex( start );
20
21 image>SetRegions( region );
22 image>Allocate();
23
24 ImageType::PixelType initialValue;
25 initialValue.Fill( 0.0 );
26 image>FillBuffer( initialValue );
27 const ImageType::IndexType pixelIndex = }; //对应像素索引位置
28 //由于向量类从 itk::FixedArray 类继承了[] 操作,所以也可以使用 index 符号来访问向量成员
29 ImageType::PixelType pixelValue;
30 pixelValue[0] = 1.345; // x cponent
31 pixelValue[1] = 6.841; // y cponent
32 pixelValue[2] = 3.295; // x cponent
33
34 std::cout << "pixelIndex索引处给定的向量值:" << std::endl;
35 std::cout << pixelValue << std::endl;
36 //通过定义一个标识并调用 SetPixel( ) 方法来将这个向量储存到pixelIndex索引像素中
37 image>SetPixel( pixelIndex, pixelValue );
38 //获取pixelIndex处像素值value
39 ImageType::PixelType value = image>GetPixel( pixelIndex );
40 //打印像素值value
41 std::cout << "pixelIndex索引处读取的像素值:" << std::endl;
42 std::cout << value << std::endl;
43
44 return EXIT_SUCCESS;
45 }
上一篇:VTK 实例66:GPU加速光线投影体绘制
下一篇:VTK 实例58:三角剖分(表面重建)
ITK









