<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;color:#000000;"><div>Hi,<br>i try to apply a discrete gaussian filter on a serie of 3D dicom images.so i try to do what Luis said to me to read the dicom serie before and then add the discrete gaussian filter. the code that i wrote is the follwing, please 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]" << std::endl;<br> return EXIT_FAILURE;<br> }<br><br>*/<br><br> argc = 2;<br> argv[1] = "dicom";<br> argv[2] = "dicomMRA.hdr";<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>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></div></div><br>
</body></html>