<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> </P>
<P>I have a problem with itkImage.</P>
<P> </P>
<P>I want to convert raw data to itkImageType.</P>
<P> </P>
<P>I've loaded .png file using ATL::CImage class(MFC 2003). </P>
<P> </P>
<P>and I want to convert this memory data to itkImageType.</P>
<P> </P>
<P>My code is follow:</P>
<P> </P>
<P>///////////////////////////////</P>
<P> typedef itk::ImportImageFilter< BytePixelType, Dimension > ImportFilterType;<BR> ImportFilterType::Pointer importer = ImportFilterType::New();<BR> image = ImageType::New();<BR> <BR> int nx = imgBase.GetWidth();<BR> int ny = imgBase.GetHeight();</P>
<P> ImageType::SizeType size;<BR> size[0] = nx;<BR> size[1] = ny;</P>
<P> ImageType::IndexType start;<BR> start.Fill(0);</P>
<P> ImageType::RegionType region;<BR> region.SetSize( size );<BR> region.SetIndex( start );<BR> importer->SetRegion( region );</P>
<P> double origin[2];<BR> origin[0] = 0; //originX;<BR> origin[1] = 0; //originY;<BR> importer->SetOrigin( origin );</P>
<P> double spacing[2];<BR> spacing[0] = 1; //dx;<BR> spacing[1] = 1; //dy;<BR> importer->SetSpacing( spacing );</P>
<P> const int totalNumberOfPixels = nx * ny;<BR> BytePixelType *pixelData = static_cast< BytePixelType * >( (BYTE *)imgBase.GetBits() );<BR>// BytePixelType *pixelData = new BytePixelType[totalNumberOfPixels];<BR>// pixelData = static_cast< BytePixelType * >( (BYTE *)imgBase.GetBits() );</P>
<P> const bool importFilterWillDeleteTheInputBuffer = false;<BR> importer->SetImportPointer( pixelData,<BR> totalNumberOfPixels,<BR> importFilterWillDeleteTheInputBuffer );</P>
<P> importer->Update();<BR> image->GetInput( importer->GetOutput() );</P>
<P> typedef itk::ImageFileWriter<ImageType> WriterType;<BR> WriterType::Pointer writer = WriterType::New();<BR>// writer->SetInput( filter->GetOutput() );<BR> writer->SetInput( image );<BR> writer->SetFileName("output.bmp");<BR> try<BR> {<BR> writer->Update();<BR> }<BR> catch( itk::ExceptionObject & exp ) <BR> {<BR> std::cerr << "Exception caught !" << std::endl;<BR> std::cerr << exp << std::endl;<BR> }</P>
<P>///////////////</P>
<P> </P>
<P>width and height is same. but image data is nothing</P>
<P> </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>