创建一个itk::Image,并写入到png文件
#include "itkImage.h"
#include <vtkSmartPointer.h>
#include <vtkPNGWriter.h>
#include <itkImageToVTKImageFilter.h>
#include <iostream>
void CreateImage(itk::Image<unsigned char, 2>* const image)
{
// Create an image with 2 connected components
itk::Image<unsigned char, 2>::IndexType start = { {0,0} };
start[0] = 0;
start[1] = 0;
itk::Image<unsigned char, 2>::SizeType size;
unsigned int NumRows = 200;
unsigned int NumCols = 300;
size[0] = NumRows;
size[1] = NumCols;
typename itk::Image<unsigned char, 2>::RegionType region(start, size);
image->SetRegions(region);
image->Allocate();
// Make a square
for (itk::Image<unsigned char, 2>::Ind
本文档介绍了如何通过ITK库创建一个itk::Image对象,并利用ITK和VTK的互操作性,将其转换为VTK图像格式,最终使用vtkPNGWriter将其保存为PNG文件。
订阅专栏 解锁全文
1072

被折叠的 条评论
为什么被折叠?



