Transfer from VTK to SimpleITK

Great ! Seem to go, now I have to try the outcome, for the moment I have no error !!! I hope is ok … Now I stop the work for 24 hours, but I come back here with feedback ! @zivy & @blowekamp & @dzenanz Thank you !!!

Here is my new code that seem to go without errors:

sitk::ImportImageFilter importer;

int* nDim = m_pDICOMReader->GetOutput()->GetDimensions();
TRACE(">>>>%d|%d|%d\n", nDim[0], nDim[1], nDim[2]);
uint8_t* in = new uint8_t[nDim[0] * nDim[1] * nDim[2]];

double* dSpacing = m_pDICOMReader->GetOutput()->GetSpacing();
std::vector<double> spacing;
spacing.push_back(dSpacing[0]);
spacing.push_back(dSpacing[1]);
spacing.push_back(dSpacing[2]);
importer.SetSpacing(spacing);
double* dOrigin = m_pDICOMReader->GetOutput()->GetOrigin();
std::vector<double> origin;
origin.push_back(dOrigin[0]);
origin.push_back(dOrigin[1]);
origin.push_back(dOrigin[2]);
importer.SetOrigin(origin);
std::vector<unsigned int> size;
size.push_back((unsigned int)nDim[0]);
size.push_back((unsigned int)nDim[1]);
size.push_back((unsigned int)nDim[2]);
importer.SetSize(size);
importer.SetBufferAsUInt8(in);

try
{
	sitk::Image img = importer.Execute();
}
catch (sitk::GenericException& error)
{
	::SendMessage(theApp.m_pMainWnd->GetSafeHwnd(), WM_SETMESSAGESTRING, 0, (LPARAM)error.GetDescription());
}

delete[] in;
1 Like