[Insight-users] how to read analyze image
Jihan Zoghbi
jihanzoghbi at gmail.com
Tue Sep 23 14:17:46 EDT 2008
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.
// generated 2008/9/11 11:12:04 BRT by talita at shafrira.(none)
// using glademm V2.6.0
//
// newer (non customized) versions of this file go to window1.cc_new
// This file is for your program, I won't touch it again!
#include <vtkRenderWindowInteractor.h>
#include <itkImage.h>
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkImageToVTKImageFilter.h>
#include <vtkImageViewer.h>
#include <gtkmm/stock.h>
#include <gtkmm/filechooserdialog.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkOutlineFilter.h>
#include <vtkCamera.h>
#include <vtkStripper.h>
#include <vtkLookupTable.h>
#include <vtkImageDataGeometryFilter.h>
#include <vtkProperty.h>
#include <vtkPolyDataNormals.h>
#include <vtkContourFilter.h>
#include <vtkImageData.h>
#include <vtkImageMapToColors.h>
#include <vtkImageActor.h>
#include <vtkDICOMImageReader.h>
#include <vtkImageGaussianSmooth.h>
#include <vtkVolume16Reader.h>
#include "vtkmm.h"
#include "config.h"
#include "window1.hh"
window1::window1() : window1_glade()
{
this->signal_check_resize().connect(sigc::mem_fun(*this,
&window1::checkResize));
// Creates a widget for VTK rendering
renArea = new class Gtk::Vtk::RenderingArea();
renderer = renArea->get_vtk_renderer();
renderer->SetBackground(0,0,0);
renArea2 = new class Gtk::Vtk::RenderingArea();
renderer2 = renArea2->get_vtk_renderer();
renderer2->SetBackground(0,0,0);
renArea3 = new class Gtk::Vtk::RenderingArea();
renderer3 = renArea3->get_vtk_renderer();
renderer3->SetBackground(0,0,0);
// Reserves 200 pixels for the VTK widget
hpaned1->set_position(800);
fixed1->set_size_request(400,(this->get_height())/2);
fixed2->set_size_request(400,(this->get_height())/2);
fixed3->set_size_request(400,(this->get_height())/2);
// Passes it to the startButton
//selectButton->setRenderArea(renArea);
// Adds the VTK widget to its reserved area
fixed1->add(*renArea);
fixed2->add(*renArea2);
fixed3->add(*renArea3);
renArea->show();
renArea2->show();
renArea3->show();
this->maximize();
}
void window1::on_analyze1_activate()
{
}
void window1::on_dicom1_activate()
{
//Gtk::FileChooserDialog dialog("Please choose a
file",Gtk::FILE_CHOOSER_ACTION_OPEN);
//dialog.set_transient_for(*this);
//Add response buttons the the dialog:
//dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
//dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
//Add filters, so that only certain file types can be selected:
//Gtk::FileFilter filter_dicom;
//filter_dicom.set_name("DICOM images");
//filter_dicom.add_pattern("*");
//dialog.add_filter(filter_dicom);
//int result = dialog.run();
int result = 0;
//Handle the response:
switch(result)
{
case(0)://case(Gtk::RESPONSE_OK):
{
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/projeto3/src/Fatias";//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 );
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->Render();
viewer->SetColorWindow( 255 );
viewer->SetColorLevel( 128 );
renderWindowInteractor->Start();
//writer->SetFileName(strFolderPath );
//writer->SetInput( reader->GetOutput() );
// vtkDICOMImageReader *reader = vtkDICOMImageReader::New();
//vtkImageViewer *viewer = vtkImageViewer::New();
//viewer->SetInput(reader->GetOutput());
//reader->SetDirectoryName("/home/jihan/projeto3/src/Fatias");
//reader->Update();
// int VolData_Images = viewer->GetWholeZMax ();
//for (int i=0;i<=VolData_Images;i++)
/*{
viewer->SetZSlice(10);
viewer->GetRenderer()->ResetCameraClippingRange();
viewer->SetColorWindow(400);
viewer->SetColorLevel(128);
viewer->Render();
//}*/
//reader->Delete();
//viewer->Delete();
break;
}
case(Gtk::RESPONSE_CANCEL):
{
std::cout << "Cancel clicked." << std::endl;
break;
}
default:
{
std::cout << "Unexpected button clicked." << std::endl;
break;
}
}
}
void window1::on_abrir1_activate()
{
}
void window1::on_salvar1_activate()
{
}
void window1::on_sair1_activate()
{
this->hide();
}
void window1::on_sobre1_activate()
{
}
void window1::checkResize()
{
renArea->set_size_request(fixed1->get_width(),
(this->get_height())/2);
//renArea2->set_size_request(fixed2->get_width(),
(this->get_height())/2);
//renArea3->set_size_request(fixed3->get_width(),
(this->get_height())/2);
}
The following is my code :
2008/9/10 Luis Ibanez <luis.ibanez at kitware.com>
> Hi Jihan,
>
>
> Welcome to ITK !
>
> Please read the ITK Software Guide
>
> http://www.itk.org/ItkSoftwareGuide.pdf
>
> in partiular, you should read the Chapter
>
> "Reading and Writing Images"
>
>
> You will find in that text, that the way of
> reading this Analyze image is described in
> the Example:
>
> Insight/Examples/IO/ImageReadWrite.cxx
>
> and that you only need to change line 95, from:
>
> const unsigned int Dimension = 2;
>
> to:
>
> const unsigned int Dimension = 3;
>
>
> Please give it a try at this example.
>
>
> Regards,
>
>
> Luis
>
>
> ------------------
> Jihan Zoghbi wrote:
>
>> Hi Everybody,
>> I´am a itk new users and I want to read to know how does Itk read images
>> of type anaylize (the files are of extensions .hdr and .img )with the
>> following features:
>> # Contraste: T1
>> # Matriz: 512 x 512 x 232
>> # Space resolution: 0.469 x 0.469 x 0.8mm
>> # 16 bits/voxel
>> # cut orientation: Axial-plane
>> Somebody can help me?
>> Best Regards...
>> _______________
>>
>>
>> Jihan Zoghbi
>> "Desire for others what you desire for yourself, and you will be the most
>> just of men"
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>
--
Jihan Zoghbi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080923/c50f54f1/attachment-0001.htm>
More information about the Insight-users
mailing list