- /*std::vector<unsigned short int> ImageData;
- typename InputImageType::IndexType pixelIndex;
- int l=0;
- unsigned short int pixelValue;
- //DD(highestValue);
- for (int i=0; i<NbFrames; i++){
- pixelIndex[2] = i;
- for (int j=0; j<NbRows; j++){
- pixelIndex[1] = j;
- for (int k=0; k<NbCols; k++){
- pixelIndex[0] = k;
- pixelValue=image->GetPixel(pixelIndex)/doseScaling;
- if(float(image->GetPixel(pixelIndex)/doseScaling)>(pow(2,16)-1.)) {
- std::cout<<"\n!!!!! WARNING !!!!! pixel index: "<<pixelIndex<<"unsigned short int capacity ful or overfuled => Highest value may become 0"<<std::endl;
- DD(pixelIndex);
- DD(image->GetPixel(pixelIndex));
- //DD(image->GetPixel(pixelIndex)/doseScaling);
- DD(pixelValue);
- std::cout<<"Pixel Value should be equal to "<<(pow(2,16)-1)<<" but should not be 0"<<std::endl;
- std::cout<<"\n"<<std::endl;
- //assert(pixelValue<=(pow(2,16)-1)); should work, but do not...
- }
- //DD(pixelValue);
- ImageData.push_back(pixelValue);
- l++;
- }
- }
- }
- DD(ImageData.size());*/
-
- // Read Dicom model file
- typename ReaderSeriesType::Pointer readerSeries = ReaderSeriesType::New();
- ImageIOType::Pointer gdcmIO = ImageIOType::New();
- std::string filename_out = m_ArgsInfo.output_arg;
- gdcmIO->LoadPrivateTagsOn();
- gdcmIO->KeepOriginalUIDOn();
- typename ReaderSeriesType::FileNamesContainer fileNames;
- fileNames.push_back(m_ArgsInfo.DicomInputFile_arg);
- readerSeries->SetImageIO( gdcmIO );
- readerSeries->SetFileNames( fileNames );
- try {
- readerSeries->Update();
- } catch (itk::ExceptionObject &excp) {
- std::cerr << "Error: Exception thrown while reading the DICOM model file !!" << std::endl;
- std::cerr << excp << std::endl;
+ typename OutputImageType::Pointer imageOutput = OutputImageType::New();
+ imageOutput->SetRegions(image->GetLargestPossibleRegion());
+ imageOutput->SetSpacing(image->GetSpacing());
+ imageOutput->SetOrigin(image->GetOrigin());
+ imageOutput->SetDirection(image->GetDirection());
+ imageOutput->Allocate();
+
+ typename itk::ImageRegionConstIterator<InputImageType> imageIterator(image,image->GetLargestPossibleRegion());
+ typename itk::ImageRegionIterator<OutputImageType> imageOutputIterator(imageOutput,imageOutput->GetLargestPossibleRegion());
+ while(!imageIterator.IsAtEnd()) {
+ // Set the current pixel to white
+ imageOutputIterator.Set((signed short int)(imageIterator.Get()/doseScaling));
+
+ ++imageIterator;
+ ++imageOutputIterator;