[Insight-users] display analyze image em 2D and 3D
Jihan Zoghbi
jihanzoghbi at gmail.com
Sun Sep 28 08:35:33 EDT 2008
Dear Luis,
Thanks for your help, I have already succeed to read and visualize Analyze
Image. I'm facing a new problem now, when I'm trying to read and visualize
Dicom Image , I got a problem to view the slides in the correct order. I
used the following code:
/*******************************************/
char dir_name[]="/home/talita/Desktop/COMUNIX/Neck 1HEAD_NECK_PETCT/CT
HEAD-NK 5.0 B30s";
dicom_info = vtkImageData::New();
dicom_info = vtkITKMyUtilityLoadImage<unsigned short,1>(dir_name);
/*****************************************************/
void window1::addAxialSlice(int slice_number)
{
int *extent;
extent = dicom_info->GetWholeExtent();
renderer->RemoveActor(axial);
axialColors = vtkImageMapToColors::New();
SetInputConnection(image->GetOutputPort());
axialColors->SetInput(dicom_info);
axialColors->SetLookupTable(hueLut);
axial = vtkImageActor::New();
axial->SetInput(axialColors->GetOutput());
axial->SetDisplayExtent(0,extent[1], 0,extent[3],
slice_number,slice_number);
axial->SetPosition(0,0,0);
renderer->AddActor(axial);
renderer->ResetCameraClippingRange();
renArea->queue_draw();
}
/******************************************************/
template <class IT,int choice>
vtkImageData* vtkITKMyUtilityLoadImage(char* fname)
{
typedef itk::Image< IT, 3 > ImageType;
typedef itk::ImageToVTKImageFilter<ImageType> ImageToVTKImageFilterType;
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::ImageSeriesReader< ImageType > ReaderType2;
typename ReaderType::Pointer reader = ReaderType::New();
typename ReaderType2::Pointer reader2 = ReaderType2::New();
typename ImageToVTKImageFilterType::Pointer
exporter=ImageToVTKImageFilterType::New();
if (choice==0){
reader->SetFileName(fname);
try{
reader->Update();
}
catch (itk::ExceptionObject & e)
{
std::cerr << "Failed to read " << fname << "\n" <<
e.GetDescription() << std::endl;
return NULL;
}
exporter->SetInput(reader->GetOutput());
}
if (choice==1){
itk::DICOMImageIO2::Pointer dicomIO = itk::DICOMImageIO2::New();
// Get the DICOM filenames from the directory
itk::DICOMSeriesFileNames::Pointer nameGenerator =
itk::DICOMSeriesFileNames::New();
nameGenerator->SetDirectory(fname);
try
{
typedef std::vector<std::string> seriesIdContainer;
const seriesIdContainer & seriesUID =
nameGenerator->GetSeriesUIDs();
seriesIdContainer::const_iterator seriesItr = seriesUID.begin();
seriesIdContainer::const_iterator seriesEnd = seriesUID.end();
std::cout << std::endl << "The directory: " << std::endl;
std::cout << std::endl << fname << std::endl << std::endl;
std::cout << "Contains the following DICOM Series: ";
std::cout << std::endl << std::endl;
while( seriesItr != seriesEnd )
{
std::cout << seriesItr->c_str() << std::endl;
seriesItr++;
}
std::cout << std::endl << std::endl;
std::cout << "Now reading series: " << std::endl << std::endl;
typedef std::vector<std::string> fileNamesContainer;
fileNamesContainer fileNames;
std::cout << seriesUID.begin()->c_str() << std::endl;
fileNames = nameGenerator->GetFileNames();
std::cout << std::endl << std::endl;
reader2->SetFileNames( fileNames );
reader2->SetImageIO( dicomIO );
try{
reader2->Update();
}
catch (itk::ExceptionObject & e)
{
std::cerr << "Failed to read " << fname << "\n" <<
e.GetDescription() << std::endl;
return NULL;
}
exporter->SetInput(reader2->GetOutput());
}
catch (itk::ExceptionObject &ex)
{
std::cout << ex;
return NULL;
}
}
exporter->Update();
vtkImageData* output=vtkImageData::New();
output->DeepCopy(exporter->GetOutput());
return output;
}
P.S: This renderer is a Rendering Area of vtkmm.
Best Regards..
2008/9/27 Luis Ibanez <luis.ibanez at kitware.com>
>
> Hi Jihan,
>
> Please describe what is "different" about the image when you display it.
>
> Also, what are you using for displaying the image ?
>
> Have you used the ImageViewer to visualize the image ?
> You will find it in the InsightApplications module.
>
>
> Regards,
>
>
> Luis
>
>
> --------------------
> Jihan Zoghbi wrote:
>
>>
>> Hi all,
>> I have a set of Analyze Image. I used ITK to read the .hdr file and it got
>> all right. I export this image to vtk, I'm facing a great problem to display
>> a 2D Slice. I already checked the header data like: Spacing, Extent, Origin
>> ..and everything is ok! I 'm using unsigned short as a pixel type. I used
>> the vtkExtractVOI to extract a 2D slice, but when I try to visualize it, i
>> got a total different image. Could anybody help me?
>>
>> Regards
>> --
>> Jihan Zoghbi
>>
>> --
>> Jihan Zoghbi
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> 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/20080928/2731096b/attachment.htm>
More information about the Insight-users
mailing list