<html><head><style>P {margin-top:2px;margin-bottom:2px;}</style></head><body><div style="font-size:8pt; font-family:Gulim,AppleGothic,sans-serif;"><P>Hi all.</P>
<P>&nbsp;</P>
<P>I have a problem with itkImage.</P>
<P>&nbsp;</P>
<P>I want to convert raw data to&nbsp;itkImageType.</P>
<P>&nbsp;</P>
<P>I've loaded .png file using ATL::CImage class(MFC 2003). </P>
<P>&nbsp;</P>
<P>and I want to convert this memory data to itkImageType.</P>
<P>&nbsp;</P>
<P>My code is follow:</P>
<P>&nbsp;</P>
<P>///////////////////////////////</P>
<P>&nbsp; typedef itk::ImportImageFilter&lt; BytePixelType, Dimension &gt; ImportFilterType;<BR>&nbsp; ImportFilterType::Pointer importer = ImportFilterType::New();<BR>&nbsp; image = ImageType::New();<BR>&nbsp; <BR>&nbsp; int nx = imgBase.GetWidth();<BR>&nbsp; int ny = imgBase.GetHeight();</P>
<P>&nbsp; ImageType::SizeType size;<BR>&nbsp; size[0] = nx;<BR>&nbsp; size[1] = ny;</P>
<P>&nbsp; ImageType::IndexType start;<BR>&nbsp; start.Fill(0);</P>
<P>&nbsp; ImageType::RegionType region;<BR>&nbsp; region.SetSize( size );<BR>&nbsp; region.SetIndex( start );<BR>&nbsp; importer-&gt;SetRegion( region );</P>
<P>&nbsp; double origin[2];<BR>&nbsp; origin[0] = 0;&nbsp;//originX;<BR>&nbsp; origin[1] = 0;&nbsp;//originY;<BR>&nbsp; importer-&gt;SetOrigin( origin );</P>
<P>&nbsp; double spacing[2];<BR>&nbsp; spacing[0] = 1;&nbsp;//dx;<BR>&nbsp; spacing[1] = 1;&nbsp;//dy;<BR>&nbsp; importer-&gt;SetSpacing( spacing );</P>
<P>&nbsp; const int totalNumberOfPixels = nx * ny;<BR>&nbsp; BytePixelType *pixelData = static_cast&lt; BytePixelType * &gt;( (BYTE *)imgBase.GetBits() );<BR>//&nbsp;&nbsp; BytePixelType *pixelData = new BytePixelType[totalNumberOfPixels];<BR>//&nbsp;&nbsp; pixelData = static_cast&lt; BytePixelType * &gt;( (BYTE *)imgBase.GetBits() );</P>
<P>&nbsp; const bool importFilterWillDeleteTheInputBuffer = false;<BR>&nbsp; importer-&gt;SetImportPointer( pixelData,<BR>&nbsp;&nbsp; totalNumberOfPixels,<BR>&nbsp;&nbsp; importFilterWillDeleteTheInputBuffer );</P>
<P>&nbsp; importer-&gt;Update();<BR>&nbsp; image-&gt;GetInput( importer-&gt;GetOutput() );</P>
<P>&nbsp; typedef itk::ImageFileWriter&lt;ImageType&gt; WriterType;<BR>&nbsp; WriterType::Pointer writer = WriterType::New();<BR>//&nbsp; writer-&gt;SetInput( filter-&gt;GetOutput() );<BR>&nbsp; writer-&gt;SetInput( image );<BR>&nbsp; writer-&gt;SetFileName("output.bmp");<BR>&nbsp; try<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer-&gt;Update();<BR>&nbsp; }<BR>&nbsp; catch( itk::ExceptionObject &amp; exp ) <BR>&nbsp; {<BR>&nbsp;&nbsp; std::cerr &lt;&lt; "Exception caught !" &lt;&lt; std::endl;<BR>&nbsp;&nbsp; std::cerr &lt;&lt; exp &lt;&lt; std::endl;<BR>&nbsp; }</P>
<P>///////////////</P>
<P>&nbsp;</P>
<P>width and height is same. but image data is nothing</P>
<P>&nbsp;</P>
<P>help me..</P></div></body></html><!--navermail.footer.start-->

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="3" height="25"></td></tr>
<tr><td colspan="3" height="1" bgcolor="#ECECEC"></td></tr>
<tr><td colspan="3" height="12"></td></tr>
<tr><td align="right" style="padding-right:5px;"><a href="http://www.naver.com/" target="_blank" style="color:#4F4F30"><img src="http://static.naver.com/mail4/lg_happybeen_01.gif" width="53" height="24" alt="" style="border: none;"></a><a href="http://happybean.naver.com/main/SectionMain.nhn" target="_blank" style="color:#4F4F30"><img src="http://static.naver.com/mail4/lg_happybeen_02.gif" width="45" height="24" alt="" style="border: none;"></a></td></tr>
<tr><td colspan="3" height="14"></td></tr>
</table>

<!--navermail.footer.end-->
                                                                                   
<table style='display:none'><tr><td><IMG SRC="http://mail1.naver.com/newmailcheck/vXYwFoI8+rwSaxvXhAnrM4u/FqbrMxblFrFCF4uwMrpvFAIoKx+opAvrMvIGFouXaxtQar05br0N1HtR+BF0bNFg1B3O74eZpm==.gif" border=0></td></tr></table>