[Insight-users] how to read analyze image

Jihan Zoghbi jihanzoghbi at gmail.com
Wed Sep 24 10:22:28 EDT 2008


Hi luis,
Thank you for your help. Now I got another problem, I already read the
analyze image the way that you explain to me. The problem is that i can not
visualize em 3D. the following is my code. Thanks again for your help.


       typedef 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();
       typedef itk::ImageToVTKImageFilter< ImageType> ConnectorType;

       std::cout << "Open clicked." << std::endl;

       //Notice that this is a std::string, not a Glib::ustring.
       std::string strFolderPath =
"/home/jihan/Desktop/projeto3/src/Fatias/s9.hdr";//dialog.get_filename();//
//     std::cout << "File selected: " <<  strFolderPath << std::endl;
        std::cout << "Open clicked....2." << std::endl;

       //vtkRenderer *renderer = renArea->get_vtk_renderer();
       //vtkRenderer *renderer2 = renArea2->get_vtk_renderer();
       //vtkRenderer *renderer3 = renArea3->get_vtk_renderer();
       // Removes any object that was there before
       renderer->RemoveAllViewProps();
       //renderer2->RemoveAllViewProps();
       //renderer3->RemoveAllViewProps();


       reader->SetFileName( strFolderPath  );
       writer->SetFileName("outputImage.hdr");
       writer->SetInput( reader->GetOutput() );
       writer->Update();


       std::cout << "Open clicked....3." << std::endl;
       ConnectorType::Pointer connector = ConnectorType::New();
       connector->SetInput( reader->GetOutput() );
       vtkImageViewer * viewer = vtkImageViewer::New();
       vtkRenderWindowInteractor * renderWindowInteractor =
vtkRenderWindowInteractor::New();
       viewer->SetupInteractor( renderWindowInteractor );

       viewer->SetInput( connector->GetOutput() );
       viewer->SetZSlice(10);
       viewer->Render();
       viewer->SetColorWindow( 255 );
       viewer->SetColorLevel( 128 );
       renderWindowInteractor->Start();


2008/9/24 Luis Ibanez <luis.ibanez at kitware.com>

>
>
> Hi Jihan,
>
> The error message says:
>
>   "Couldn't open file: /home/jihan/projeto3/src/Fatias"
>
>
> As you can see,
> you are not passing the correct image filename to the reader.
>
>
> The name should be
>
>        "/home/jihan/projeto3/src/Fatias.hdr"
>
>
> That is,
> the filename *extension* ".hdr" must be included as part
> of the image filename.
>
>
>   Regards,
>
>
>      Luis
>
>
> =====================
> Jihan Zoghbi wrote:
>
>> Hi Luiz,
>>
>> thank for your help, I tried to do what exactly you told me. My program
>> try  to read and visualize Analyze image file reading these two types of
>> files(.hdr and .img) . Actually, the program is reading the .hdr and .img,
>> but how can the program get the information from .hdr file and use to read
>> the .img file?  After running the program I can not visualize my image and I
>>  got the following errors:
>>
>> Couldn't open file: /home/jihan/projeto3/src/Fatias
>> ERROR: In /usr/local/VTK/Imaging/vtkImageImport.cxx, line 324
>> vtkImageImport (0x9fb3f48): Calling UpdateInformationCallback:
>> /usr/local/include/InsightToolkit/IO/itkImageFileReader.txx:144:
>>  Could not create IO object for file /home/jihan/projeto3/src/Fatias
>> The file doesn't exist.
>>
>>


-- 
Jihan Zoghbi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080924/36b2d72b/attachment-0001.htm>


More information about the Insight-users mailing list