[Insight-users] RE: Read Image from File Problem

Steven Chen itkvtk at yahoo.com
Fri, 2 Jan 2004 07:35:00 -0800 (PST)


--0-726237681-1073057700=:62530
Content-Type: text/plain; charset=us-ascii

Hi, All
 
Happy New Year!
 
I encountered a problem in reading image from file. 
The image type i used is .pgm format.
 
The code is as follows:
**********************************************************************

#include "itkImage.h"

#include "itkImageFileReader.h"

int main()

{

const unsigned int Dimension = 3;

typedef itk::Image< PixelType, Dimension > ImageType;





typedef itk::ImageFileReader< ImageType > ReaderType;







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

reader ->SetFileName("C:\image.pgm");


  reader->Update();

  ImageType::Pointer image = reader->GetOutput();
reader->Update();ImageType::Pointer image = reader->GetOutput();





return 0;

}


 

********************************************************

 

There is always some runtime error in itkImageFileReader 

Hope you help !

 

Thanks a lot.

 

Steven Chen




---------------------------------
Do you Yahoo!?
Find out what made the Top Yahoo! Searches of 2003
--0-726237681-1073057700=:62530
Content-Type: text/html; charset=us-ascii

<DIV>Hi, All</DIV>
<DIV>&nbsp;</DIV>
<DIV>Happy New Year!</DIV>
<DIV>&nbsp;</DIV>
<DIV>I encountered a problem in reading image from file. </DIV>
<DIV>The image type i used is .pgm format.</DIV>
<DIV>&nbsp;</DIV>
<DIV>The code is as follows:</DIV>
<DIV>**********************************************************************</DIV>
<DIV><FONT color=#0000ff size=2>
<P><STRONG>#include</STRONG></FONT><FONT size=2><STRONG> "itkImage.h"</STRONG></FONT></P>
<P><STRONG><FONT color=#0000ff size=2>#include</FONT><FONT size=2> "itkImageFileReader.h"</P></FONT></STRONG>
<P><FONT color=#0000ff size=2><STRONG>int</STRONG></FONT><FONT size=2><STRONG> main()</STRONG></P>
<P><STRONG>{</STRONG></P>
<P></FONT><STRONG><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>int</FONT></STRONG><FONT size=2><STRONG> Dimension = 3;</STRONG></P>
<P></FONT><FONT color=#0000ff size=2><STRONG>typedef</STRONG></FONT><FONT size=2><STRONG> itk::Image&lt; PixelType, Dimension &gt; ImageType;</STRONG></P>
<P></FONT>
<P><STRONG><FONT color=#008000 size=2></P></FONT><FONT size=2></FONT></STRONG>
<P><FONT color=#008000 size=2></P></FONT><FONT size=2></FONT><STRONG><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::ImageFileReader&lt; ImageType &gt; ReaderType;</FONT></STRONG></P>
<P>
<P><STRONG><FONT color=#008000 size=2></P></FONT><FONT size=2></FONT></STRONG>
<P><FONT color=#008000 size=2></P></FONT><FONT size=2></FONT>
<P><STRONG><FONT color=#008000 size=2></P></FONT></STRONG><FONT size=2><STRONG>ReaderType::Pointer reader = ReaderType::New();</STRONG></P>
<P><STRONG>reader -&gt;SetFileName("C:\image.pgm");</STRONG></FONT><FONT color=#008000 size=2></P></FONT><FONT size=2>
<P></FONT>
<P><STRONG>&nbsp; reader-&gt;Update();</STRONG></P>
<P><STRONG>&nbsp; ImageType::Pointer image = reader-&gt;GetOutput();<FONT color=#008000 size=2></P></FONT><FONT size=2>reader-&gt;Update();</FONT></STRONG><FONT size=2><STRONG>ImageType::Pointer image = reader-&gt;GetOutput();</STRONG></P>
<P></FONT>
<P><STRONG><FONT color=#008000 size=2></P></FONT><FONT size=2></FONT></STRONG>
<P><FONT color=#008000 size=2></P></FONT><FONT size=2></FONT><FONT color=#0000ff size=2><STRONG>return</STRONG></FONT><FONT size=2><STRONG> 0;</STRONG></P>
<P><STRONG>}</STRONG></P></FONT></DIV>
<P>&nbsp;</P>
<P>********************************************************</P>
<P>&nbsp;</P>
<P>There is always some runtime error in itkImageFileReader </P>
<P>Hope you help !</P>
<P>&nbsp;</P>
<P>Thanks a lot.</P>
<P>&nbsp;</P>
<P>Steven Chen</P><BR><BR><p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://search.yahoo.com/top2003">Find out what made the Top Yahoo! Searches of 2003
</a>
--0-726237681-1073057700=:62530--