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

Jeffrey Li chyumm at yahoo.com
Fri, 9 Apr 2004 07:46:43 -0700 (PDT)


--0-331317491-1081522003=:2838
Content-Type: text/plain; charset=us-ascii

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 - Enter today
--0-331317491-1081522003=:2838
Content-Type: text/html; charset=us-ascii

<DIV>Dear all,<BR><BR>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<BR>was alright, but the program crashed in run time. The error message's<BR>"Couldn't open file ./circle.png". I tried to debug it. When I commented<BR>out the sentence "viewer-&gt;SetInput( connector-&gt;GetOutput() );", it worked<BR>fine, and a small black window came out. Did anyone meet the same problem?<BR>Is the sample correct? <BR><BR>P.S. My working environment is .Net 2003<BR><BR>Thanks a lot!<BR><BR>Attached is the code<BR><BR>#include "itkImage.h"<BR>#include "itkImageFileReader.h"<BR>#include "itkImageToVTKImageFilter.h"<BR>#include "itkImageFileWriter.h"<BR><BR>#include "vtkImageViewer.h"<BR>#include "vtkRenderWindowInteractor.h"<BR><BR>int main( int argc, char **argv ) {<BR><BR>typedef itk::Image &lt;unsigned char,2&gt; ImageType;<BR>typedef itk::ImageFileReader &lt;ImageType&gt;
 ReaderType;<BR>typedef itk::ImageToVTKImageFilter &lt;ImageType&gt; ConnectorType;<BR>typedef itk::ImageFileWriter &lt;ImageType&gt; WriterType;<BR><BR>ReaderType::Pointer reader = ReaderType::New();<BR>ConnectorType::Pointer connector = ConnectorType::New();<BR>WriterType::Pointer writer = WriterType::New();<BR><BR>reader-&gt;SetFileName( "D:circle.png");<BR>connector-&gt;SetInput( reader-&gt;GetOutput() );<BR><BR>vtkImageViewer * viewer = vtkImageViewer::New();<BR><BR>vtkRenderWindowInteractor * renderWindowInteractor =<BR>vtkRenderWindowInteractor::New();<BR><BR>viewer-&gt;SetInput( connector-&gt;GetOutput() );<BR><BR>viewer-&gt;SetColorWindow( 255 );<BR>viewer-&gt;SetColorLevel( 128 );<BR>viewer-&gt;SetupInteractor( renderWindowInteractor );<BR><BR>viewer-&gt;Render();<BR>renderWindowInteractor-&gt;Start();<BR><BR>return 0;<BR>}<BR><BR>J. Li<BR><BR></DIV><p><hr size=1><font face=arial size=-1>Do you Yahoo!?<br>
<a href="http://us.rd.yahoo.com/evt=23609/*http://promotions.yahoo.com/design_giveaway/static/index2.html">Yahoo! Small Business $15K Web Design Giveaway</a> - Enter today
--0-331317491-1081522003=:2838--