[Rtk-users] insert .dcm

safdary mohsen ieee.safdary at gmail.com
Tue Apr 7 09:17:02 EDT 2015


Hi
My code for Reconstruction is shown in the following
this code work very well for .hnd and .his projection but when i insert
.dcm projection, the output(reconstructed image) is black completely
please solve this problem for me(10 .dcm projections and reconstructed
image(just one slice) are attached to mail)


int main(int , char **)
{

  //// variable
  typedef itk::Image< float, 3 > ImageType;
  typedef rtk::ConstantImageSource< ImageType > ConstantImageSourceType;

/////////////////////////////////////////////////////////////////////////////////////////////////////
  // Generate file names of projections
  itk::RegularExpressionSeriesFileNames::Pointer names =
itk::RegularExpressionSeriesFileNames::New();

names->SetDirectory(std::string("E://RTK/RTK-BUILD/bin/Debug/dcmprojection/"));
  names->SetRegularExpression(std::string(".*.dcm"));

  //// set projection file

////////////////////////////////////////////////////////////////////////////////////////////////////
  //// geometry
  // Defines the RTK geometry object
   typedef rtk::ThreeDCircularProjectionGeometry GeometryType;
  GeometryType::Pointer geometry = GeometryType::New();

  // Projection matrices
  unsigned int numberOfProjections = 10;
  unsigned int firstAngle = 0;
  unsigned int angularArc = 360;
  unsigned int sid = 1000; // source to isocenter distance in mm
  unsigned int sdd = 1500; // source to detector distance in mm
  int isox = 0; // X coordinate on the projection image of isocenter
  int isoy = 0; // Y coordinate on the projection image of isocenter

  for(unsigned int noProj=0; noProj<numberOfProjections; noProj++)
    {
    double angle = (float)firstAngle + (float)noProj * angularArc /
(float)numberOfProjections;
    geometry->AddProjection(sid,
                            sdd,
                            angle,
                            isox,
                            isoy);
    }


/////////////////////////////////////////////////////////////////////////////////////////////////////

 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // Projections reader

  typedef rtk::ProjectionsReader< ImageType > ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileNames(names->GetFileNames());


 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   // Create reconstructed image
                  ////////////////////////////////////

  ConstantImageSourceType::Pointer constantImageSource =
ConstantImageSourceType::New();
  ConstantImageSourceType::PointType origin;
  ConstantImageSourceType::SpacingType spacing;
  ConstantImageSourceType::SizeType sizeOutput;

  origin[0] = -127.75;//12.875
  origin[1] = -127.75;//30
  origin[2] = -127.75;//12.875

  // Adjust size according to geometry
  sizeOutput[0] = 512;//512
  sizeOutput[1] = 512;
  sizeOutput[2] = 512;

  spacing[0] = .5;//.25
  spacing[1] = .5;
  spacing[2] = .5;

  constantImageSource->SetOrigin( origin );
  constantImageSource->SetSpacing( spacing );
  constantImageSource->SetSize( sizeOutput );
  constantImageSource->SetConstant( 0. );

                    //////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  std::cout << "Performing reconstruction" << std::endl;
   // FDK reconstruction filtering
  typedef rtk::FDKConeBeamReconstructionFilter< ImageType> FDKCPUType;
  FDKCPUType::Pointer feldkamp = FDKCPUType::New();
  feldkamp->SetInput( 0, constantImageSource->GetOutput() );
  feldkamp->SetInput( 1, reader->GetOutput());
  feldkamp->SetGeometry( geometry);
   feldkamp->Update();

  std::cout << "Writing output image" << std::endl;

  // Writer
  typedef itk::ImageFileWriter<ImageType> WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetFileName( "output11.mha" );//mha
  //writer->SetUseCompression(true);
  writer->SetInput( feldkamp->GetOutput() );
  writer->Update();

   std::cout << "Done" << std::endl;
    return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/rtk-users/attachments/20150407/1024317b/attachment-0008.html>


More information about the Rtk-users mailing list