Hi, mengqiu, <br><br>try to change the image dimension to 3.<br><br>const   unsigned int        Dimension = 3;<br><br><br>wanlin<br><br><div class="gmail_quote">On Wed, Jul 6, 2011 at 11:16 PM, Mengqiu Tian <span dir="ltr">&lt;<a href="mailto:tianmengqiu@gmail.com">tianmengqiu@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi all,<br><br>I have  a  question.<br><br>I have a raw image which contains 125 frames. <br>
The mhd file as follows:<br><br>
          NDims = 3<br>DimSize = 512 512 125<br>ElementSpacing = 0.333 0.333 0.333<br>Position = 0 0 0<br>ElementByteOrderMSB = False<br>ElementNumberOfChannels = 1<br>ElementType = MET_SHORT<br>ElementDataFile = ctA0-512x512x125x16.raw<br>

<br>I could read it and then write all frames to another image &#39;test.raw&#39; by using RawImageIO class.<br>How could I realize it with MetaImageIO class? My program as follows, and I added a filter which mulitply the image by a constant 100. However, I could filter only the first frame and write it to test.raw<br>

<br>#include &quot;itkImage.h&quot;<br>#include &quot;itkImageFileReader.h&quot;<br>#include &quot;itkImageFileWriter.h&quot;<br>#include &quot;itkMetaImageIO.h&quot;<br>#include &quot;itkWeightedImageFilter.h&quot;<br>int main( int argc, char ** argv)<br>

{<br>  typedef unsigned short      PixelType;<br>  const   unsigned int        Dimension = 2;<br>  typedef itk::Image&lt; PixelType, Dimension &gt;    ImageType;<br>  typedef itk::ImageFileReader&lt; ImageType &gt;     ReaderType;<br>

  typedef itk::MetaImageIO                      ImageIOType;<br> <br>  const char * inputFilename  = &quot;ctA0-512x512x125x16.mhd&quot;;<br>  const char * outputFilename = &quot;test.mhd&quot;;<br>  const short weight = 100;<br>

<br>  ReaderType::Pointer reader = ReaderType::New();<br>  ImageIOType::Pointer metaIn = ImageIOType::New();<br><br>  reader-&gt;SetFileName( inputFilename );<br>  reader-&gt;SetImageIO(metaIn);<br>  reader-&gt;Update();<br>

<br>  typedef itk::WeightedImageFilter&lt;ImageType, ImageType&gt;        FilterType;<br>
  FilterType::Pointer  filter = FilterType::New();<br><br>  filter-&gt;SetInput( reader -&gt;GetOutput());<br>  filter-&gt;SetWeight(weight);<br>  filter-&gt;Update();<br><br>   typedef itk::ImageFileWriter&lt; ImageType &gt;     WriterType;<br>

  WriterType::Pointer writer = WriterType::New();<br>  ImageIOType::Pointer metaOut = ImageIOType::New();<br><br>  writer-&gt;SetImageIO( metaOut );<br>  writer-&gt;SetFileName( outputFilename );<br>  writer-&gt;SetInput( filter-&gt;GetOutput() );<br>

  writer-&gt;Update();<br>   <br>  return EXIT_SUCCESS;<br>}<br>               <br><br><br><br><br>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>