[Insight-users] Questions about Getting Started with ITK+VTK

Luis Ibanez luis.ibanez at kitware.com
Fri, 09 Apr 2004 11:47:29 -0400


Hi Jeffrey,

The error message seems to be clear enough,
your program is not finding the input image
file "./circle.png".  Therefore it cannot
feed the rest of the pipeline.

When the ImageFileReader can't locate a file,
it throws and ITK exception, that is then
converted to a Python exception (thanks to
Charl Botha who took the time of making this
connection).


So the problem is related to the line:

 > reader->SetFileName( "D:circle.png");

meaning that this filename doesn't seems
to be valid.  You probably want to try
"D:\circle.png" if the file is actually
in the root directory of the "D:" drive.



   Regards,



      Luis


------------------
Jeffrey Li wrote:

> Dear all,
> 
> I'm a beginner of ITK and VTK. I got a problem when I ran the example named
> " Getting Started Two", the "Getting Started with ITK+VTK". The compilation
> was alright, but the program crashed in run time. The error message's
> "Couldn't open file ./circle.png". I tried to debug it. When I commented
> out the sentence "viewer->SetInput( connector->GetOutput() );", it worked
> fine, and a small black window came out. Did anyone meet the same problem?
> Is the sample correct?
> 
> P.S. My working environment is .Net 2003
> 
> Thanks a lot!
> 
> Attached is the code
> 
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageToVTKImageFilter.h"
> #include "itkImageFileWriter.h"
> 
> #include "vtkImageViewer.h"
> #include "vtkRenderWindowInteractor.h"
> 
> int main( int argc, char **argv ) {
> 
> typedef itk::Image <unsigned char,2> ImageType;
> typedef itk::ImageFileReader <ImageType> ReaderType;
> typedef itk::ImageToVTKImageFilter <ImageType> ConnectorType;
> typedef itk::ImageFileWriter <ImageType> WriterType;
> 
> ReaderType::Pointer reader = ReaderType::New();
> ConnectorType::Pointer connector = ConnectorType::New();
> WriterType::Pointer writer = WriterType::New();
> 
> reader->SetFileName( "D:circle.png");
> connector->SetInput( reader->GetOutput() );
> 
> vtkImageViewer * viewer = vtkImageViewer::New();
> 
> vtkRenderWindowInteractor * renderWindowInteractor =
> vtkRenderWindowInteractor::New();
> 
> viewer->SetInput( connector->GetOutput() );
> 
> viewer->SetColorWindow( 255 );
> viewer->SetColorLevel( 128 );
> viewer->SetupInteractor( renderWindowInteractor );
> 
> viewer->Render();
> renderWindowInteractor->Start();
> 
> return 0;
> }
> 
> J. Li
> 
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway 
> <http://us.rd.yahoo.com/evt=23609/*http://promotions.yahoo.com/design_giveaway/static/index2.html> 
> - Enter today