[Insight-users] Questions about Getting Started with ITK+VTK
Luis Ibanez
luis.ibanez at kitware.com
Fri, 09 Apr 2004 13:59:07 -0400
Hi Jeffrey,
There is definitely something
special about your "D" drive. :-)
Maybe you forgot to mention something
like:
- It is a drive shared from another machine ?
- It has different access permissions ?
This doesn't seems to be a problem related
to ITK at all. It is very likely that the following
plain C++ code will also fail in your machine:
---------------------------------------------
#include <iostream>
int main()
{
std::ifstream file;
file.open("D:\\circle.png");
if( file.fail() )
{
std::cerr << "Impossible to open file" << std::endl;
return -1;
}
std::cout << "File can be open " << std::endl;
file.close();
return 0;
}
------------------------------
Regards
Luis
-----------------
Jeffrey Li wrote:
> Dear Luis,
>
> I've solved the problem but it seemed wield to me. I copied the file to
> the C drive, and modified the code to "C:Circle.png", it worked! I saw
> that picture. And I tried "C:\Circle.png", the warning message showed
> out, but it also worked fine. I even tried to copy the file to an
> external hard disc (F drive), and everything was fine with both
> "F:Circle.png" and "F:\Circle.png". It really looks wield to me. Seems
> there are some problems with my D drive. I installed the itk and vtk on
> the D drive, will it be the problem?
>
> Thanks a lot!
>
> Sincerely,
>
> Jeff
>
> */Luis Ibanez <luis.ibanez at kitware.com>/* wrote:
>
>
> 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< BR>> " 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 ImageType;
> > typedef itk::ImageFileReader ReaderType;
> > typedef itk::ImageToVTKImageFilter ConnectorType;
> > typedef itk::ImageFileWriter 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
> >
> > - Enter today
>
> ------------------------------------------------------------------------
> 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