[Insight-users] Issues reading and displaying complex image file
ankit master
ankit.master at gmail.com
Tue Nov 8 15:16:13 EST 2011
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\complexImage
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