[Insight-users] Normalization and Rescale Intensity

Luis Ibanez luis.ibanez at kitware.com
Wed Mar 12 17:14:22 EDT 2008



Hi Ignacio,

Since you are normalizing each slice independently of the others
you may want to do this, not by loading the Slices as a volume,
but by processing each slice by itself.


Here is one suggested way to proceed:



1) Use the GDCMSeriesFileNames class for gathering
    the filenames of all the slices that belong to a single
    DICOM series.

    Code like:

   typedef itk::GDCMSeriesFileNames NamesGeneratorType;
   NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();

   nameGenerator->SetUseSeriesDetails( true );
   nameGenerator->AddSeriesRestriction("0008|0021" );

   nameGenerator->SetDirectory( argv[1] );

   typedef std::vector< std::string >    SeriesIdContainer;
   const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs()

   std::string seriesIdentifier = seriesUID.begin()->c_str();

   typedef std::vector< std::string >   FileNamesContainer;
   FileNamesContainer fileNames;

   fileNames = nameGenerator->GetFileNames( seriesIdentifier );


   So far, fileNames is an std::vector of std::string containg
   the list of filenames of the first DICOM series found in
   the directory that you provided in argv[1]


   [This code was extracted from the example:
   Insight/Examples/IO/DicomSeriesReadImageWrite2.cxx




2) Setup a pipeline where you read one 2D file, pass it through
    a normalization, and then write it on another directory.

    Use the RescaleIntensity image filter:
http://www.itk.org/Insight/Doxygen/html/classitk_1_1RescaleIntensityImageFilter.html


    with code like:

    typedef signed short                            InputPixelType;
    typedef itk::Image< InputPixelType, 2 >         InputImageType;
    typedef itk::ImageFileReader< InputImageType >  ReaderType;

    typedef float                                   OutputPixelType;
    typedef itk::Image< OutputPixelType, 2 >        OutputImageType;
    typedef itk::ImageFileWriter< OutputImageType > WriterType;

    ReaderType::Pointer reader = ReaderType::New();
    WriterType::Pointer writer = WriterType::New();

    typedef itk::RescaleIntensityImageFilter<
        InputImageType, OutputImageType >   FilterType;

    FilterType::Pointe scaler = FilterType::New();

    scaler->SetInput( reader->GetOutput() );
    writer->SetInput( scaler->GetOutput() );

    scaler->SetOutputMaximum( 1.0 );
    scaler->SetOutputMinimum( 0.0 );

    FileNamesContainer::const_iterator filenameItr = fileNames.begin();
    while( filenameItr != fileNames.end() )
       {
       reader->SetFileName( *filenameItr );
       std::string outputFilename = outputDir + *filenameItr;
       writer->SetFileName( outputFilename );
       writer->Update();
       ++filenameItr;
       }



Disclaimer: This was typed directly on thunderbird,
             I haven't compiled this code, so you may have to
             rework the details.


Note that your output files will have pixels of type float
and with values between 0.0 and 1.0.



      Regards,


          Luis


-----------------------------
Ignacio García Fenoll wrote:
> Good morning, itk-users!
> 
> I have to read a directory with a DICOM serie and to write one new 
> directory with modified DICOM series.
> 
> The first and the second modification are:
> 
> 1. Normalization filter to all the slices, that is,
> im_min=min(slice);
> im_max=max(slice);
> new_slice=(slice - im_min)/(im_max - im_min)
> 
> 2. Rescale Intensity Filter, something similar to "imadjust" in Matlab.
> 
> Please, do you know some example to show me how to do that?
> 
> Thank you very much!
> 
> Regards.
> 
> -- 
> Ignacio García Fenoll
> Grupo de Imágenes Médicas
> Departamento de Teoría de la Señal y Comunicaciones
> Universidad de Sevilla
> e-mail: igfenoll at gmail.com <mailto:igfenoll at gmail.com>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list