Я закодировал метод создания изображения Itk из буфера (в моем случае это тип изображения Cimg). Это algorithme:ITK Импорт данных изображения из буфера
void Cimg_To_ITK (CImg<uchar> img)
{
const unsigned int Dimension = 2;
typedef itk::RGBPixel< unsigned char > RGBPixelType;
typedef itk::Image< RGBPixelType, Dimension > RGBImageType;
typedef itk::ImportImageFilter< RGBPixelType, Dimension > ImportFilterType;
ImportFilterType::Pointer importFilter = ImportFilterType::New();
typedef itk::ImageFileWriter<RGBImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
RGBImageType::SizeType imsize;
imsize[0] = img.width();
imsize[1] = img.height();
ImportFilterType::IndexType start;
start.Fill(0);
ImportFilterType::RegionType region;
region.SetIndex(start);
region.SetSize(imsize);
importFilter->SetRegion(region);
const itk::SpacePrecisionType origin[ Dimension ] = { 0.0, 0.0 };
importFilter->SetOrigin(origin);
const itk::SpacePrecisionType spacing[ Dimension ] = { 1.0, 1.0 };
importFilter->SetSpacing(spacing);
const unsigned int numberOfPixels = imsize[0] * imsize[1];
const bool importImageFilterWillOwnTheBuffer = true;
RGBPixelType * localBuffer = new RGBPixelType[ numberOfPixels ];
memcpy(localBuffer->GetDataPointer(), img.data(), numberOfPixels);
importFilter->SetImportPointer(localBuffer, numberOfPixels,importImageFilterWillOwnTheBuffer);
writer->SetInput(importFilter->GetOutput());
writer->SetFileName("output.png");
writer->Update();
}
я не имею, что я хочу в качестве выхода:
вход:
выход:
Да я вижу, что, но знаю, у меня есть один и тот же образ, который реплицируется 9 раз. http://img4.hostingpics.net/pics/641095output.png –