[Insight-users] Problem With ITKImageIO
吴鹏飞
wpfnihao at gmail.com
Thu Jul 5 07:57:01 EDT 2012
Hello all,
I am new to itk and tried to write my first program using itk and vtk to
show an image, but I encountered a strange problem. It seems that my itk
can’t infer from the file extension which ImageIO to use. If I commented
the phrase
reader->SetImageIO(itk::JPEGImageIO::New());
out, the error
“Could not create IO object for file E:\1340858885.jpg
Tried to create one of the following:
You probably failed to set a file suffix, or
set the suffix to an unsupported type.”
occurred, but the program worked properly with the phrase mentioned above.
See my source code attached at the end of this mail.
Is there someone can tell me why this happened?
Thanks a lot in advance!
Wu, Pengfei
Code:
_____
int main(int argc, char* argv[])
{
typedef itk::RGBPixel<unsigned short> PixelType;
const unsigned int Dimension = 2;
typedef itk::Image<PixelType, Dimension> ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
const char *filename = "E:\\1340858885.jpg";
//reader->SetImageIO(itk::JPEGImageIO::New());
reader->SetFileName(filename);
ImageType::Pointer image = reader->GetOutput();
typedef itk::ImageToVTKImageFilter<ImageType> FilterType;
FilterType::Pointer connecter = FilterType::New();
connecter->SetInput(image);
vtkImageViewer *viewer = vtkImageViewer::New();
vtkRenderWindowInteractor *renderWindowInteractor =
vtkRenderWindowInteractor::New();
viewer->SetupInteractor(renderWindowInteractor);
viewer->SetInput(connecter->GetOutput());
viewer->Render();
viewer->SetColorWindow(255);
viewer->SetColorLevel(128);
renderWindowInteractor->Start();
cin.get();
return 0;
}
-------------------------------------End of
Code-------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120705/1846e736/attachment.htm>
More information about the Insight-users
mailing list