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 'test.raw' 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 "itkImage.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>#include "itkMetaImageIO.h"<br>#include "itkWeightedImageFilter.h"<br>int main( int argc, char ** argv)<br>
{<br> typedef unsigned short PixelType;<br> const unsigned int Dimension = 2;<br> typedef itk::Image< PixelType, Dimension > ImageType;<br> typedef itk::ImageFileReader< ImageType > ReaderType;<br>
typedef itk::MetaImageIO ImageIOType;<br> <br> const char * inputFilename = "ctA0-512x512x125x16.mhd";<br> const char * outputFilename = "test.mhd";<br> const short weight = 100;<br>
<br> ReaderType::Pointer reader = ReaderType::New();<br> ImageIOType::Pointer metaIn = ImageIOType::New();<br><br> reader->SetFileName( inputFilename );<br> reader->SetImageIO(metaIn);<br> reader->Update();<br>
<br> typedef itk::WeightedImageFilter<ImageType, ImageType> FilterType;<br>
FilterType::Pointer filter = FilterType::New();<br><br> filter->SetInput( reader ->GetOutput());<br> filter->SetWeight(weight);<br> filter->Update();<br><br> typedef itk::ImageFileWriter< ImageType > WriterType;<br>
WriterType::Pointer writer = WriterType::New();<br> ImageIOType::Pointer metaOut = ImageIOType::New();<br><br> writer->SetImageIO( metaOut );<br> writer->SetFileName( outputFilename );<br> writer->SetInput( filter->GetOutput() );<br>
writer->Update();<br> <br> return EXIT_SUCCESS;<br>}<br> <br><br><br><br><br>