[Insight-users] Re: itkimagt to vtkimage?: No BMP reader in ITK

Luis Ibanez luis.ibanez@kitware.com
Sun, 23 Mar 2003 10:54:44 -0500


Hi Zhao,

ITK doesn't have a BMP reader at this point.

You may try converting this BMP image to a
format like PNG, for which ITK has readers.

A good set of tools for performing such
conversions is available in ImageMagick.

You can download it for free from

      http://www.imagemagick.org/


You could also use the VTK BMP reader in
order to bring the image into memory,
then use the VTKImageToImage adaptor in
order to convert the vtkImageData into
an itk::Image.

Please take a look at
http://www.vtk.org/doc/nightly/html/classvtkBMPReader.html



Regards,


    Luis



----------------------------------
zhao yong qiang wrote:
> Hi luis,
> 
>     I write the following code translate itkimage to vtkimage and 
> display the image
> 
>  
> 
> typedef unsigned char          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("f://medical images//00013E9A_01.bmp");
> 
>  
> 
>   reader->Update();
> 
>   ImageType::Pointer image = reader->GetOutput();
> 
>  
> 
>   typedef itk::ImageToVTKImageFilter<ImageType>  vtkImageType;
> 
>  
> 
>   vtkImageType::Pointer vtkimage = vtkImageType::New();
> 
>   vtkImageWriter* writer = vtkImageWriter::New();
> 
>   vtkimage->SetInput(image);
> 
>   vtkImageData* imagedata = vtkImageData::New();
> 
>   imagedata = vtkimage->GetOutput();
> 
>  
> 
>   vtkImageViewer* viewer = vtkImageViewer::New();
> 
>   viewer->SetInput(imagedata);
> 
>   viewer->Render();  
> 
>   viewer->Delete();
> 
>  
> 
> compiling is fine, but execution has debug error..
> 
> how to solve it?
> 
>  
> 
> Sincerely,
>                           Zhao Yongqiang
>                           Dept. of Computer Science & Engineering
>                           Shanghai JiaoTong University
>                           Shanghai, China
>                           zhao-yq@cs.sjtu.edu.cn 
> <mailto:zhao-yq@cs.sjtu.edu.cn>
> 
>  
>