[Insight-users] 2Djpg -> 3Dgipl
Petra Schneider
petraschneider at arcor.de
Fri Jan 21 07:47:54 EST 2005
Dear All,
I would like to use VTK CISG-RegistrationToolkit to register a set of 2D
images, originally in .jpg. Out of this reason, I have to convert my files to
gipl-format, but failed until now.
I tried to use the simple IO example provided by ITK (see Code below, I tried
different PixelValues). The results look good, but vtkview always crashes, if
I try to load the new generated files.
vtkconvert didn't read the jpg-files.I don't know, if it doesn't accept jpg in
principle (perhaps, the reason just lies in the wrong dimensionality...)
Has anybody done this before?
How can I convert the jpg files to gipl format (or any other format compatible
with VTK CISG)?
Thanks in advance,
Petra
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkImage.h"
int main (int argc, char ** argv)
{
if (argc < 2)
{
std :: cerr << "Usage: " << std :: endl;
std :: cerr << argv [0] << " inputImageFile " <<std::endl;
return -1;
}
typedef unsigned short PixelType;
const unsigned int Dimension = 3;
typedef itk :: Image <PixelType, Dimension> ImageType;
typedef itk :: ImageFileReader <ImageType> ReaderType;
typedef itk :: ImageFileWriter <ImageType> WriterType;
ReaderType :: Pointer reader (ReaderType :: New ());
WriterType :: Pointer writer (WriterType :: New ());
reader -> SetFileName (argv [1]);
writer -> SetFileName ("myImage.gipl");
writer -> SetInput (reader->GetOutput ());
try
{
writer->Update();
}
catch (itk :: ExceptionObject& err)
{
std :: cout << "ExceptionObject caught !" << std :: endl;
std :: cout << err << std :: endl;
return -1;
}
return 0;
}
More information about the Insight-users
mailing list