<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV> </DIV>
<DIV>Hi Shirani</DIV>
<DIV
style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt"><BR> </DIV>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">First of
all you need to learn C++ properly and Read the ITK software user guide can be
download from here. <STRONG>Remember one advice for free “Half effect doesn’t
produce Half Result , It produce nothing.” <IMG
style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-TOP-STYLE: none; BORDER-LEFT-STYLE: none"
class="wlEmoticon wlEmoticon-smile" alt=Smile
src="cid:7AD6092C1D814A2893362675A2453D2B@nareshPC"></STRONG></DIV>
<DIV
style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt"> </DIV>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt"><A
href="http://www.itk.org/ItkSoftwareGuide.pdf"><FONT
face="Times New Roman">http://www.itk.org/ItkSoftwareGuide.pdf</FONT></A><FONT
face="Times New Roman"> </FONT></DIV>
<DIV
style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt"> </DIV>
<DIV
style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt"> </DIV>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">Also in
your sample it doesnot make any sense what you trying to do because since you
reading .mhd file there is no need for ImageSeriesReader because </DIV>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">when you
load .mhd file it will load the associate .raw file with sequence given in .mhd
file. Also in your e-mail your not telling peoples what you want to do </DIV>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">in that
case no one can help you . </DIV>
<DIV
style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt"> </DIV>
<DIV
style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt"> </DIV>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">So Correct
you code like as given. It will load your 3D RGB image and produce the slice as
color png images. Is that what you loooking for ?</DIV>
<DIV
style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt"> </DIV>
<DIV> </DIV>
<DIV>#include "itkImage.h"</DIV>
<DIV>#include "itkRGBPixel.h"</DIV>
<DIV>#include "itkImageFileReader.h"</DIV>
<DIV>#include "itkImageSeriesWriter.h"</DIV>
<DIV>#include "itkNumericSeriesFileNames.h"</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>typedef unsigned
char
PixelType;</DIV>
<DIV>const unsigned int Dimension = 3;</DIV>
<DIV> </DIV>
<DIV>typedef
itk::RGBPixel<PixelType>
RGBPixelType;</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>typedef itk::Image< RGBPixelType, Dimension> ImageType;</DIV>
<DIV> </DIV>
<DIV>typedef itk::ImageFileReader<ImageType >
ReaderType;</DIV>
<DIV>typedef itk::ImageFileWriter< ImageType > WriterType;</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>ReaderType::Pointer reader = ReaderType::New();</DIV>
<DIV>reader->SetFileName( "D:\\To_SMK\\VHPAbdomen%03d.mhd" );</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>const unsigned int first = atoi( argv[1] );</DIV>
<DIV>const unsigned int last = atoi( argv[2] );</DIV>
<DIV>const char * outputFilename = argv[3];</DIV>
<DIV> </DIV>
<DIV>typedef itk::NumericSeriesFileNames
NameGeneratorType;</DIV>
<DIV>NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();</DIV>
<DIV>nameGenerator->SetSeriesFormat( "vwe%03d.png" );</DIV>
<DIV>nameGenerator->SetStartIndex( first );</DIV>
<DIV>nameGenerator->SetEndIndex( last );</DIV>
<DIV>nameGenerator->SetIncrementIndex( 1 );</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>typedef itk::Image< RGBPixelType, 2 >
Image2DType;</DIV>
<DIV> </DIV>
<DIV>typedef itk::ImageSeriesWriter< ImageType, Image2DType >
SeriesWriterType;</DIV>
<DIV>SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();</DIV>
<DIV>seriesWriter->SetInput( reader->GetOutput() );</DIV>
<DIV>seriesWriter->SetFileNames( nameGenerator->GetFileNames() );</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>try</DIV>
<DIV>{ </DIV>
<DIV> seriesWriter->Update();</DIV>
<DIV>}</DIV>
<DIV>catch( itk::ExceptionObject & excp )</DIV>
<DIV>{</DIV>
<DIV> std::cerr << "Error reading the series " <<
std::endl;</DIV>
<DIV> std::cerr << excp << std::endl;</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Alex</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV
style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt"> </DIV>
<DIV
style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt"> </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> </DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=bill.lorensen@gmail.com
href="mailto:bill.lorensen@gmail.com">Bill Lorensen</A> </DIV>
<DIV><B>Sent:</B> Wednesday, September 19, 2012 4:55 AM</DIV>
<DIV><B>To:</B> <A title=mangalika673@gmail.com
href="mailto:mangalika673@gmail.com">shirani kannangara</A> </DIV>
<DIV><B>Cc:</B> <A title=insight-users@itk.org
href="mailto:insight-users@itk.org">insight-users@itk.org</A> </DIV>
<DIV><B>Subject:</B> Re: [Insight-users] read and write image
series</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">Change
this line:
<DIV><SPAN
style="BACKGROUND-COLOR: rgb(255,255,255); FONT-FAMILY: arial,sans-serif; FONT-SIZE: 13px">
if( argc <4 );</SPAN></DIV>
<DIV><FONT face="arial, sans-serif">to</FONT></DIV>
<DIV><SPAN
style="BACKGROUND-COLOR: rgb(255,255,255); FONT-FAMILY: arial,sans-serif; FONT-SIZE: 13px">
if( argc <4 )</SPAN></DIV>
<DIV><FONT face="arial, sans-serif"><BR></FONT><BR>
<DIV class=gmail_quote>On Tue, Sep 18, 2012 at 6:23 AM, shirani kannangara <SPAN
dir=ltr><<A href="mailto:mangalika673@gmail.com"
target=_blank>mangalika673@gmail.com</A>></SPAN> wrote:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote><BR>Hi vtk/itk users<BR>
<DIV class=gmail_quote>I am constructing a program to read and write medical
image(3D) data set ,
<DIV>image data(raw data -VHPAbdomen.mhd)in ITk version 4.2 ,CMake2.8.9. IT
built with 2 warnings.</DIV>
<DIV>itk codes are as follows.But it does not display output properly. It is
as follows.My raw data file is attached herewith.I used
ImageSeriesReadWrite.cxx</DIV>
<DIV>#include "itkImage.h"</DIV>
<DIV><SPAN style="WHITE-SPACE: pre-wrap"></SPAN>#include
"itkImageSeriesReader.h"</DIV>
<DIV><SPAN style="WHITE-SPACE: pre-wrap"></SPAN>#include
"itkImageFileWriter.h"</DIV>
<DIV><SPAN style="WHITE-SPACE: pre-wrap"></SPAN>#include
"itkNumericSeriesFileNames.h"</DIV>
<DIV><SPAN style="WHITE-SPACE: pre-wrap"></SPAN>#include
"itkPNGImageIO.h"</DIV>
<DIV><B><BR></B></DIV>
<DIV><B><BR></B></DIV>
<DIV><B>codes</B></DIV>
<DIV>
<DIV> </DIV>
<DIV> <SPAN style="WHITE-SPACE: pre-wrap"></SPAN>#include
<iostream></DIV>
<DIV> #include <string></DIV>
<DIV> <SPAN style="WHITE-SPACE: pre-wrap"></SPAN>using namespace
std;</DIV>
<DIV> </DIV>
<DIV><SPAN style="WHITE-SPACE: pre-wrap"></SPAN></DIV>
<DIV>int main( int argc, char **argv[])</DIV>
<DIV> </DIV>
<DIV>{</DIV>
<DIV> if( argc <4 );</DIV>
<DIV> </DIV>
<DIV> {std::cout << "Usage: " << std::endl;</DIV>
<DIV> std::cout<<argv[0] << "
firstSliceValue lastSliceValue outputImageFile " <<
std::endl;</DIV>
<DIV> return EXIT_FAILURE;</DIV>
<DIV> }<SPAN style="WHITE-SPACE: pre-wrap"> </SPAN></DIV>
<DIV> </DIV>
<DIV> //std::cout<<"sliceValue:"<<std::endl;</DIV>
<DIV> typedef unsigned
char
PixelType;</DIV>
<DIV> const unsigned int<SPAN style="WHITE-SPACE: pre-wrap">
</SPAN> Dimension = 3;</DIV>
<DIV> </DIV>
<DIV> typedef itk::Image< PixelType, Dimension>
ImageType;</DIV>
<DIV> </DIV>
<DIV> typedef itk::ImageSeriesReader< ImageType >
ReaderType;</DIV>
<DIV> typedef itk::ImageFileWriter< ImageType >
WriterType;</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> ReaderType::Pointer reader = ReaderType::New();</DIV>
<DIV> WriterType::Pointer writer = WriterType::New();</DIV>
<DIV> </DIV>
<DIV> const unsigned int first = 1;</DIV>
<DIV> const unsigned int last = 450;</DIV>
<DIV> //char * outputFilename = argv[3];</DIV>
<DIV> char**outputFilename= argv[3];</DIV>
<DIV> </DIV>
<DIV> typedef itk::NumericSeriesFileNames NameGeneratorType;</DIV>
<DIV> </DIV>
<DIV> NameGeneratorType::Pointer nameGenerator =
NameGeneratorType::New();</DIV>
<DIV> </DIV>
<DIV> nameGenerator->SetSeriesFormat(
"D:\\To_SMK\\VHPAbdomen%03d.mhd" );</DIV>
<DIV> nameGenerator->SetStartIndex( first );</DIV>
<DIV> nameGenerator->SetEndIndex( last);</DIV>
<DIV> nameGenerator->SetIncrementIndex(1);</DIV>
<DIV> </DIV>
<DIV> reader->SetImageIO( itk::PNGImageIO::New() );</DIV>
<DIV> </DIV>
<DIV> reader->SetFileNames( nameGenerator->GetFileNames()
);</DIV>
<DIV> writer->SetInput( reader->GetOutput() );</DIV>
<DIV> writer->SetFileName("test.mhd");</DIV>
<DIV>try</DIV>
<DIV> {</DIV>
<DIV> writer->Update();</DIV>
<DIV> }</DIV>
<DIV> catch( itk::ExceptionObject & err )</DIV>
<DIV> {</DIV>
<DIV> std::cerr << "ExceptionObject caught !" <<
std::endl;</DIV>
<DIV> std::cerr << err << std::endl;</DIV>
<DIV> return EXIT_FAILURE;</DIV>
<DIV> };</DIV>
<DIV> </DIV>
<DIV> return 0;</DIV>
<DIV> </DIV>
<DIV> }</DIV>
<DIV> </DIV></DIV>
<DIV><B>OUTPUT</B> </DIV>
<DIV> </DIV>
<DIV>D:\image\Debug>ImageReadWrite.exe</DIV>
<DIV>Usage:</DIV>
<DIV>0022D9E0 firstSliceValue lastSliceValue outputImageFile</DIV>
<DIV> </DIV>
<DIV>D:\image\Debug>ImageReadWrite.exe(1 450 test.mhd)</DIV>
<DIV>Usage:</DIV>
<DIV>00E71324 firstSliceValue lastSliceValue outputImageFile</DIV>
<DIV> </DIV>
<DIV>D:\image\Debug>ImageReadWrite.exe(1,450,test.mhd)</DIV>
<DIV>Usage:</DIV>
<DIV>0115131C firstSliceValue lastSliceValue outputImageFile</DIV>
<DIV> </DIV>
<DIV>D:\image\Debug></DIV>
<DIV> </DIV>
<DIV>PL help me to get it corrected</DIV>
<DIV>Thankas </DIV><SPAN class=HOEnZb><FONT color=#888888><SPAN><FONT
color=#888888>
<DIV> </DIV>
<DIV>Shirani</DIV></FONT></SPAN></FONT></SPAN></DIV><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.php"
target=_blank>http://www.kitware.com/products/protraining.php</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><BR
clear=all>
<DIV> </DIV>-- <BR>Unpaid intern in BillsBasement at noware dot
com<BR><BR></DIV>
<P>
<HR>
_____________________________________<BR>Powered by www.kitware.com<BR><BR>Visit
other Kitware open-source projects
at<BR>http://www.kitware.com/opensource/opensource.html<BR><BR>Kitware offers
ITK Training Courses, for more information
visit:<BR>http://www.kitware.com/products/protraining.php<BR><BR>Please keep
messages on-topic and check the ITK FAQ
at:<BR>http://www.itk.org/Wiki/ITK_FAQ<BR><BR>Follow this link to
subscribe/unsubscribe:<BR>http://www.itk.org/mailman/listinfo/insight-users<BR></DIV></DIV></DIV></BODY></HTML>