[Insight-users] Issues reading and displaying complex image file

Antonio Gómez Barquero agb1 at alu.upct.es
Wed Nov 9 03:33:05 EST 2011


 

Hi,

 

You could try t oread the complex image file ( if the format is supported),
because I think that the problema is the fact that you try to read this
binary file.

 

Antonio

 

 

De: insight-users-bounces at itk.org [mailto:insight-users-bounces at itk.org] En
nombre de ankit master
Enviado el: martes, 08 de noviembre de 2011 21:16
Para: insight-users at itk.org
Asunto: [Insight-users] Issues reading and displaying complex image file

 

Hello, 

 

I am trying to read a complex image file (one with real and imaginary parts)
and want to display the real and imaginary parts separately. 

 

I simulated some complex data and have written it down into a binary file.
In this program I am reading the binary file and trying to look at just the
real part for now. Everytime I do so I get an exception. 

 

 

 




#include <iostream >

#include "itkImage.h"

#include "itkImageFileReader.h"

#include "itkImageFileWriter.h"

#include "itkImageToVTKImageFilter.h"

#include "itkVnlFFTRealToComplexConjugateImageFilter.h"

#include "itkComplexToRealImageFilter.h"

#include "itkComplexToImaginaryImageFilter.h"

#include "vtkImageViewer.h"

#include "vtkRenderWindowInteractor.h"

 

#include <string>

 

int main (int argc, char** argv)

{

            std::string filename =
"C:\\Users\\amaster\\Desktop\\AVM\_Documents\\ITK_Practise\\myProject\_bin\\
complexImage"; 

 

            typedef itk::Image<float ,2> ImageType;   

            typedef itk::ImageFileReader <ImageType> ReaderType;   // Read
Complex image

            typedef itk::ImageToVTKImageFilter <ImageType> FilterType;  //
display itk image in vtk 

 

            typedef float PixelType; 

            const int Dimension=2; 

            

            ReaderType::Pointer reader = ReaderType::New(); 

            reader->SetFileName(filename); 

 

            typedef itk::VnlFFTRealToComplexConjugateImageFilter< PixelType,
Dimension >  FFTFilterType;

            FFTFilterType::Pointer fftFilter = FFTFilterType::New();

            fftFilter->SetInput(reader->GetOutput()); 

 

            try 

            {          fftFilter->Update(); 

            }

            catch (itk::ExceptionObject & excp )

    {

                        std::cerr << "Error: " << std::endl;

                        std::cerr << excp << std::endl;

                        return EXIT_FAILURE;

    }

            

            typedef FFTFilterType::OutputImageType  ComplexImageType;

            typedef itk::ComplexToRealImageFilter<ComplexImageType,
ImageType > RealFilterType;

            RealFilterType::Pointer realFilter = RealFilterType::New();

            realFilter->SetInput(fftFilter->GetOutput()) ; 

 

            FilterType::Pointer connector = FilterType::New();

            connector->SetInput( realFilter->GetOutput()); 

 

 

            vtkImageViewer *viewer = vtkImageViewer::New(); 

            vtkRenderWindowInteractor * renWinInt =
vtkRenderWindowInteractor::New(); 

 

            viewer->SetupInteractor( renWinInt); 

            viewer->SetInput(connector->GetOutput()); 

            viewer->Render(); 

            viewer->SetColorWindow(255); 

            viewer->SetColorLevel(128); 

            renWinInt->Start(); 

 

            system("PAUSE"); 

 

            return 0; 

 

}

 

 

exception that I get :

 

 

Could not created IO objects for file
C:\Users\amaster\Desktop\AVM\_Documents\ITK_Practise\myProject\_bin\complexI
mage

 

Tried to create one of the following, 

 

BIORadImageIO 

...  (some more image types) 

 

You probably failed to set a file suffix or set the suffix to an unsupported
type. 

 

 

 

Any help is greatly appreciated. 

 

Thank you 

Ankit 

 

 

-- 



More information about the Insight-users mailing list