<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>Hi</DIV>
<DIV> </DIV>
<DIV>Please make CC to itk user list so other can see the conversion and get
help from it.</DIV>
<DIV> </DIV>
<DIV>I seen your had some mistakes.</DIV>
<DIV> </DIV>
<DIV>1) In Series name gernerator is wrong</DIV>
<DIV><FONT face=Arial><FONT style="FONT-SIZE: 9pt"
color=#222222>nameGenerator->SetSeriesFormat("D:\\To_SMK\\VHPAbdomen.mhd");</FONT></FONT></DIV>
<DIV><FONT color=#222222 face=Arial>should be something like</FONT></DIV>
<DIV><FONT face=Arial><FONT color=#222222><FONT
style="FONT-SIZE: 9pt">nameGenerator->SetSeriesFormat("D:\\To_SMK\\VHPAbdomen%03d.mhd");</FONT></FONT></FONT></DIV>
<DIV>that it will start format the image. Suppose number 12 image name will be
<FONT face=Arial><FONT style="FONT-SIZE: 9pt"
color=#222222>VHPAbdomen012.mhd</FONT></FONT></DIV>
<DIV> </DIV>
<DIV>2) <FONT color=#222222 face="arial, sans-serif"><SPAN><FONT
style="FONT-SIZE: 9pt"> writer->SetFileName( "test.png" ); You
can’t save the 3D image as png. You have to save like meta image (i.e.
.mha)</FONT></SPAN></FONT></DIV>
<DIV><FONT color=#222222
face="arial, sans-serif"><SPAN></SPAN></FONT> </DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN>3) </SPAN></FONT><FONT
color=#222222 face="arial, sans-serif"><SPAN><FONT style="FONT-SIZE: 9pt">
nameGenerator->SetSeriesFormat( "test.png" ); also simlar to
nameGenerator->SetSeriesFormat( "vwe%03d.png" );</FONT></SPAN></FONT></DIV>
<DIV><FONT color=#222222
face="arial, sans-serif"><SPAN></SPAN></FONT> </DIV>
<DIV><FONT color=#222222
face="arial, sans-serif"><SPAN></SPAN></FONT> </DIV>
<DIV><FONT color=#222222
face="arial, sans-serif"><SPAN></SPAN></FONT> </DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN>For more details see the
attached example from ITK. </SPAN></FONT><FONT color=#222222
face="arial, sans-serif"><SPAN>Pls check all this and let us know the
result.</SPAN></FONT></DIV>
<DIV><FONT color=#222222
face="arial, sans-serif"><SPAN></SPAN></FONT> </DIV>
<DIV><FONT color=#222222
face="arial, sans-serif"><SPAN></SPAN></FONT> </DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN>alex</SPAN></FONT></DIV>
<DIV><FONT color=#222222
face="arial, sans-serif"><SPAN></SPAN></FONT> </DIV>
<DIV><FONT color=#222222
face="arial, sans-serif"><SPAN></SPAN></FONT> </DIV>
<DIV><FONT color=#222222
face="arial, sans-serif"><SPAN></SPAN></FONT> </DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222
face="arial, sans-serif"><SPAN></SPAN></FONT> </DIV>
<DIV><FONT color=#222222 face=Arial></FONT><FONT color=#222222
face=Arial></FONT><FONT color=#222222 face=Arial></FONT><FONT color=#222222
face=Arial></FONT><BR> </DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV style="FONT: 10pt tahoma">
<DIV><FONT size=3 face=Calibri></FONT> </DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=mangalika673@gmail.com
href="mailto:mangalika673@gmail.com">shirani kannangara</A> </DIV>
<DIV><B>Sent:</B> Tuesday, September 18, 2012 11:54 AM</DIV>
<DIV><B>To:</B> <A title=alexdowson@hotmail.com
href="mailto:alexdowson@hotmail.com">alexdowson@hotmail.com</A> </DIV>
<DIV><B>Subject:</B> Re: read rgb values</DIV></DIV></DIV>
<DIV> </DIV></DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV>Dear Alex</DIV>
<DIV>1. My input file name is VHPabdomen.mhd(raw data file).It consist of
series of 2D image slices of the abdomen.Image dimensions are
675,401,450.spacing0.333.</DIV>
<DIV> </DIV>
<DIV>2I wrote codes to read rgb values of sreries of
images.</DIV>
<DIV> </DIV>
<DIV>Thanks Shirani</DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex; FONT-FAMILY: arial,sans-serif; COLOR: rgb(34,34,34); FONT-SIZE: 12px"
class=gmail_quote>
<DIV dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: calibri; FONT-SIZE: 12pt">
<DIV style="DISPLAY: inline; FONT-SIZE: small">
<DIV style="FONT-FAMILY: tahoma; FONT-SIZE: 10pt">Dear
Alex</DIV></DIV></DIV></DIV></DIV></BLOCKQUOTE>
<DIV
style="FONT-FAMILY: arial,sans-serif; COLOR: rgb(34,34,34); FONT-SIZE: 12px">Thanks
a lot you for showing me the error and now it runs with zero errors (but
there are three warnings).So far I couldn't read RGB values.Is there anything
missing in my codes.Pl help me.</DIV>
<DIV
style="FONT-FAMILY: arial,sans-serif; COLOR: rgb(34,34,34); FONT-SIZE: 12px">codes
are given below.</DIV>
<DIV
style="FONT-FAMILY: arial,sans-serif; COLOR: rgb(34,34,34); FONT-SIZE: 12px">Thanks</DIV>
<DIV
style="FONT-FAMILY: arial,sans-serif; COLOR: rgb(34,34,34); FONT-SIZE: 12px">Shirani</DIV>
<DIV
style="FONT-FAMILY: arial,sans-serif; COLOR: rgb(34,34,34); FONT-SIZE: 12px"> </DIV>
<DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">// RGB images are commonly used for representing
data acquired from cryogenic</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">// sections, optical microscopy and endoscopy.
This example illustrates how to</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">// read RGB color images from a set of files
containing individual 2D slices</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">// in order to compose a 3D color dataset. Then
save it into a single 3D file,</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">// and finally save it again as a set of 2D slices
with other names.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">#include "itkRGBPixel.h"</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">#include "itkImage.h"</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">#include "itkImageSeriesReader.h"</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">#include "itkImageSeriesWriter.h"</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">#include
"itkNumericSeriesFileNames.h"</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">#include "itkPNGImageIO.h"</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">#include <string></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">using namespace std;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"></SPAN></FONT> </DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">// Software Guide : EndCodeSnippet</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">int main( int argc, char * argv[] )</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">{</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><SPAN style="WHITE-SPACE: pre-wrap"></SPAN>char
test;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // Verify the number of parameters in the command
line</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> if( argc < 4 )</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> {</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> std::cout << "Usage: " <<
std::endl;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> std::cout << argv[0] <<
"first last outputRGBImageFile " << std::endl;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> return
EXIT_FAILURE;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> }</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // The \doxygen{RGBPixel} class is templated over
the type used to</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // represent each one of the Red, Green and Blue
components. A typical</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // instantiation of the RGB image class might be
as follows.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> typedef itk::RGBPixel< unsigned char
> PixelType;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> const unsigned int Dimension =
3;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> typedef itk::Image< PixelType, Dimension
> ImageType;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"></SPAN></FONT> </DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // The image type is used as a template parameter
to instantiate</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // the series reader and the volumetric
writer.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"></SPAN></FONT> </DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> typedef itk::ImageSeriesReader< ImageType
> SeriesReaderType;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> typedef itk::ImageFileWriter<
ImageType > WriterType;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> SeriesReaderType::Pointer seriesReader =
SeriesReaderType::New();</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">
WriterType::Pointer
writer =
WriterType::New();</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"></SPAN></FONT> </DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> const unsigned int first = 1;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> const unsigned int last =
450;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> //char * outputFilename =
argv[3];</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> const char*outputFilename=
argv[3];</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> //const unsigned int first = atoi( argv[1]
);</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> //const unsigned int last = atoi( argv[2]
);</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> //const char * outputFilename =
argv[3];</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // We use a NumericSeriesFileNames class in order
to generate the filenames of</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // the slices to be read. Later on in this
example we will reuse this object in</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // order to generate the filenames of the slices
to be written.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> typedef itk::NumericSeriesFileNames
NameGeneratorType;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> NameGeneratorType::Pointer nameGenerator =
NameGeneratorType::New();</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> nameGenerator->SetStartIndex( first
);</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> nameGenerator->SetEndIndex( last
);</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> nameGenerator->SetIncrementIndex( 0.333
);</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">//nameGenerator->SetSeriesFormat( "test.png"
);</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">
nameGenerator->SetSeriesFormat("D:\\To_SMK\\VHPAbdomen.mhd");</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // The ImageIO object that actually
performs the read process</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // is now connected to the
ImageSeriesReader.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> seriesReader->SetImageIO(
itk::PNGImageIO::New() );</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // The filenames of the input slices are
taken from the names generator and</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // passed to the series
reader.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> seriesReader->SetFileNames(
nameGenerator->GetFileNames() );</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // The name of the volumetric output image is
passed to the image writer, and</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // we connect the output of the series reader to
the input of the volumetric</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // writer.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> //</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> writer->SetFileName( "test.png"
);</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> writer->SetInput( seriesReader->GetOutput()
);</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // Finally, execution of the pipeline can
be triggered by invoking the</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // Update() method in the volumetric
writer. This, of course, is done from</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // inside a try/catch
block.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"></SPAN></FONT> </DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> try</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> {</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">
writer->Update();</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> }</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> catch( itk::ExceptionObject & excp
)</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> {</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> std::cerr << "Error reading the
series " << std::endl;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> std::cerr << excp <<
std::endl;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> }</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // We now proceed to save the same volumetric
dataset as a set of slices. This</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // is done only to illustrate the process for
saving a volume as a series of 2D</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // individual datasets. The type of the series
writer must be instantiated</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // taking into account that the input file is a
3D volume and the output files</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // are 2D images. Additionally, the output
of the series reader is connected</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // as input to the series
writer.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> typedef itk::Image< PixelType, 2
> Image2DType;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> typedef itk::ImageSeriesWriter< ImageType,
Image2DType > SeriesWriterType;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> SeriesWriterType::Pointer seriesWriter =
SeriesWriterType::New();</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> seriesWriter->SetInput(
seriesReader->GetOutput() );</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // We now reuse the filenames generator in order
to produce the list of</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // filenames for the output series. In this case
we just need to modify the</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // format of the filenames generator. Then, we
pass the list of output</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // filenames to the series
writer.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> nameGenerator->SetSeriesFormat( "test.png"
);</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"><BR></SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> seriesWriter->SetFileNames(
nameGenerator->GetFileNames() );</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // Finally we trigger the execution of the series
writer from inside a</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // try/catch block.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> try</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> {</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px">
seriesWriter->Update();</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> }</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> catch( itk::ExceptionObject & excp
)</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> {</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> std::cerr << "Error reading the
series " << std::endl;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> std::cerr << excp <<
std::endl;</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> }</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // You may have noticed that apart from the
declaration of the</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // \code{PixelType} there is nothing in
this code that is specific for RGB</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // images. All the actions required to
support color images are implemented</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> // internally in the \doxygen{ImageIO}
objects.</SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> </SPAN></FONT></DIV>
<DIV><FONT color=#222222 face="arial, sans-serif"><SPAN
style="FONT-SIZE: 12px"> return
EXIT_SUCCESS;</SPAN></FONT></DIV></DIV></DIV></DIV></DIV></BODY></HTML>