[Insight-users] Problem With ITKImageIO
Bill Lorensen
bill.lorensen at gmail.com
Thu Jul 5 10:19:28 EDT 2012
Please show us your CMakeLists.txt file.
On Thu, Jul 5, 2012 at 7:57 AM, 吴鹏飞 <wpfnihao at gmail.com> wrote:
> 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-------------------------------------------------------------****
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
--
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120705/82c205f2/attachment.htm>
More information about the Insight-users
mailing list