[Insight-users] Save DICOM file with IntensityWindowingImageFilterType
Brenno Ribeiro
brennobr at gmail.com
Wed Feb 6 14:43:31 EST 2013
Hi, i'm trying to saving a DICOM file into another DICOM file with some
transformation like IntensityWindowingImageFilterType adapted from the
http://www.itk.org/Wiki/ITK/Examples/DICOM/ResampleDICOM example. The only
problem that occurs it the "brightness" doesn't change on the new DICOM
file created during the process but the "contrast" changes is ok. This
snippet of code corresponds the moment that occurs the passage of
parameters to the transformation of the IntensityWindowingImageFilterType
and the moment that is written a new DICOM file.
////////////////////////////////////////////////
// "filter" is the type IntensityWindowingImageFilterType
rescaler->SetInput(reader->GetOutput());
rescaler->SetOutputMinimum( 0 ); //rescaler default to view the original
colors [0,255]
rescaler->SetOutputMaximum( 255 ); //
filter->SetInput(rescaler->GetOutput());//
filter->SetWindowLevel(intMaxWindowGlobal, intMinWindowGlobal); //(window,
level)
//parameters from a Dialog created by the main class
filter->SetWindowMinimum(intMinWindowGlobal);//Minimum Contrast
filter->SetWindowMaximum(intMaxWindowGlobal);//Maximum Contrast
filter->SetOutputMinimum(intOutMinGlobal);//Minimum Brightness
filter->SetOutputMaximum(intOutMaxGlobal);//Maximum Brightness
try
{
filter->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
}
////////////////////////////////////////////////
// 5) Write the new DICOM series
// Generate the file names
OutputNamesGeneratorType::Pointer outputNames =
OutputNamesGeneratorType::New();
std::string
seriesFormat("/home/brennobr/Source/dcm-files/teste-resample/output");
seriesFormat = seriesFormat + "/" + "IM%d.dcm";
outputNames->SetSeriesFormat (seriesFormat.c_str());
outputNames->SetStartIndex (1);
outputNames->SetEndIndex (outputSize[2]);
SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
seriesWriter->SetInput( filter->GetOutput() );
seriesWriter->SetImageIO( gdcmIO );
seriesWriter->SetFileNames( outputNames->GetFileNames() );
seriesWriter->SetMetaDataDictionaryArray( &outputArray );
try
{
seriesWriter->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Exception thrown while writing the series " << std::endl;
std::cerr << excp << std::endl;
}
std::cout << "The output series in directory " <<
"/home/brennobr/Source/dcm-files/teste-resample/output"
<< " has " << outputSize[2] << " files with spacing "
<< outputSpacing
<< std::endl;
--
Brenno Bernardes Ribeiro
Engenharia da Computação
Universidade Federal do Pará
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130206/54fab1b5/attachment.htm>
More information about the Insight-users
mailing list