创建一个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>::IndexValueType r = 10; r < 80; r++)
{
for (itk::Image<unsigned char, 2>::IndexValueType c = 20; c < 100; c++)
{
itk::Image&