<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Hi,<br>I'm really ashamed. i know i disturb you from your work.i have buy a book of c++ and i use internet but in vain i still don't know <br>many things and i still learning at the same time. i will try and try to command better c++ and itk.the begining is still difficult.Really thank you for your help but want to konw others things if itis possible:<br><br>you have said :<br>>>Do not do that. Pass the arguments in at the command line properly.<br>>>Also if argc =2 then only argv[0] and argv[1] are valid. C starts<br>>>counting at 0.<br>please explain more to me what i must do step by step:<br>how do i pass the arguments at the command line properly . it's one of my problem? what i must do exactly<br>all i know that i debogue from c++ and after that i'll
have the ms dos screen and i haven't the posibility to write the arguments in this screen because it's mentioned that i should clik to any key in the key board.<br><br>Regards<br><br><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">De :</span></b> John Drescher <drescherjm@gmail.com><br><b><span style="font-weight: bold;">À :</span></b> Syrine Sahmim <syrine.sahmim@yahoo.fr><br><b><span style="font-weight: bold;">Cc :</span></b> insight-users@itk.org<br><b><span style="font-weight: bold;">Envoyé le :</span></b> Mardi, 4 Août 2009, 14h22mn 44s<br><b><span style="font-weight: bold;">Objet :</span></b> Re: Need to correct this example<br></font><br>On Tue, Aug 4, 2009 at 7:34 AM, Syrine Sahmim<<a ymailto="mailto:syrine.sahmim@yahoo.fr"
href="mailto:syrine.sahmim@yahoo.fr">syrine.sahmim@yahoo.fr</a>> wrote:<br>> Hi,<br>> I send again the same mail because i need help really.<br>> i try to apply a discrete gaussian filter on a serie of 3D dicom images.so i<br>> try to do what Luis said to me to read the dicom serie before and then add<br>> the discrete gaussian filter. the code that i wrote is the follwing, please<br>> can you help me toi correct it. really i need help.<br>> #if defined(_MSC_VER)<br>> #pragma warning ( disable : 4786 )<br>> #endif<br>><br>> #ifdef __BORLANDC__<br>> #define ITK_LEAN_AND_MEAN<br>> #endif<br>><br>><br>> #include "itkOrientedImage.h"<br>> #include "itkGDCMImageIO.h"<br>> #include "itkGDCMSeriesFileNames.h"<br>> #include "itkImageSeriesReader.h"<br>> #include "itkImageFileWriter.h"<br>><br>><br>> #include "itkRescaleIntensityImageFilter.h"<br>> #include
"itkDiscreteGaussianImageFilter.h"<br>><br>><br>> int main( int argc, char* argv[] )<br>> {<br>><br>> /* if( argc < 3 )<br>> {<br>> std::cerr << "Usage: " << std::endl;<br>> std::cerr << argv[0] << " DicomDirectory outputFileName [seriesName]"<br>> << std::endl;<br>> return EXIT_FAILURE;<br>> }<br>><br>> */<br>><br>> argc = 2;<br>> argv[1] = "dicom";<br>> argv[2] = "dicomMRA.hdr";<br>><br><br>Do not do that. Pass the arguments in at the command line properly.<br>Also if argc =2 then only argv[0] and argv[1] are valid. C starts<br>counting at 0.<br><br>> typedef signed short PixelType;<br>> const unsigned int Dimension =
3;<br>><br>> typedef itk::OrientedImage< PixelType, Dimension > ImageType;<br>><br>> typedef itk::ImageSeriesReader< ImageType > ReaderType;<br>> ReaderType::Pointer reader = ReaderType::New();<br>><br>> typedef itk::GDCMImageIO ImageIOType;<br>> ImageIOType::Pointer dicomIO = ImageIOType::New();<br>><br>> reader->SetImageIO( dicomIO );<br>><br>> typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br>> NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();<br>><br>> nameGenerator->SetUseSeriesDetails( true );<br>> nameGenerator->AddSeriesRestriction("0008|0021" );<br>><br>> nameGenerator->SetDirectory( argv[1] );<br>><br>><br>><br>>
try<br>> {<br>> std::cout << std::endl << "The directory: " << std::endl;<br>> std::cout << std::endl << argv[1] << std::endl ;<br>> std::cout << "Contains the following DICOM Series: ";<br>> std::cout << std::endl << std::endl;<br>><br>><br>><br>> typedef std::vector< std::string > SeriesIdContainer;<br>><br>> const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();<br>><br>> SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();<br>> SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();<br>> while( seriesItr != seriesEnd )<br>> {<br>>
std::cout << seriesItr->c_str() << std::endl;<br>> seriesItr++;<br>> }<br>><br>><br>> std::string seriesIdentifier;<br>><br>> if( argc > 3 ) // If no optional series identifier<br>> {<br>> seriesIdentifier = argv[3];<br>> }<br>> else<br>> {<br>> seriesIdentifier = seriesUID.begin()->c_str();<br>> }<br>><br>><br>><br>> std::cout << std::endl << std::endl;<br>> std::cout << "Now reading series: " << std::endl << std::endl;<br>> std::cout << seriesIdentifier << std::endl;<br>>
std::cout << std::endl << std::endl;<br>><br>><br>><br>><br>><br>> typedef std::vector< std::string > FileNamesContainer;<br>> FileNamesContainer fileNames;<br>><br>> fileNames = nameGenerator->GetFileNames( seriesIdentifier );<br>><br>> reader->SetFileNames( fileNames );<br>><br>><br>><br>> try<br>> {<br>> reader->Update();<br>> }<br>> catch (itk::ExceptionObject &ex)<br>> {<br>> std::cout << ex << std::endl;<br>> return EXIT_FAILURE;<br>> }<br>><br>><br>> }<br>> catch
(itk::ExceptionObject &ex)<br>> {<br>> std::cout << ex << std::endl;<br>> return EXIT_FAILURE;<br>> }<br>><br>> typedef itk::DiscreteGaussianImageFilter<<br>> InputImageType, OutputImageType > FilterType;<br>><br>> FilterType::Pointer filter = FilterType::New();<br>> filter->SetInput( reader->GetOutput() );<br>><br><br>The following can not possibly work because you forced argc = 2<br><br>> const double gaussianVariance = atof( argv[3] );<br>> const unsigned int maxKernelWidth = atoi( argv[4] );<br>> filter->SetVariance( gaussianVariance );<br>> filter->SetMaximumKernelWidth( maxKernelWidth );<br>> filter->Update();<br>><br>><br>> typedef
unsigned char WritePixelType;<br>> typedef itk::Image< WritePixelType, 2 > WriteImageType;<br>> typedef itk::RescaleIntensityImageFilter<<br>> OutputImageType, WriteImageType > RescaleFilterType;<br>> RescaleFilterType::Pointer rescaler = RescaleFilterType::New();<br>><br>> rescaler->SetOutputMinimum( 0 );<br>> rescaler->SetOutputMaximum( 255 );<br>><br>> typedef itk::ImageFileWriter< WriteImageType > WriterType;<br>> WriterType::Pointer writer = WriterType::New();<br>> writer->SetFileName( argv[2] );<br>> rescaler->SetInput( filter->GetOutput() );<br>> writer->SetInput( rescaler->GetOutput() );<br>> writer->Update();<br>> return EXIT_SUCCESS;<br>><br>> }<br>>
thanks to all<br>><br></div></div></div><br>
</body></html>