[Insight-users] how to get the buffer data

Ali Habib ali.mahmoud.habib at gmail.com
Tue Dec 28 03:52:26 EST 2010


Dear All,
I need the pixel data as unsigned char* , I created my pipeline but I stuck
on how to get the buffer data , also I need to know does the pixel_value
will show me if the input is scaler or not

the code I use is :

typedef signed short InputPixelType;
 const unsigned int   InputDimension = 2;
  typedef itk::Image< InputPixelType, InputDimension > InputImageType;
 typedef itk::ImageFileReader< InputImageType > ReaderType;
 typedef InputImageType::SizeType         SizeType;
  ReaderType::Pointer reader = ReaderType::New();
 reader->SetFileName( "4.dcm" );
  typedef itk::GDCMImageIO           ImageIOType;
 ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
 reader->SetImageIO( gdcmImageIO );
  try
    {
 reader->Update();
    }
 catch (itk::ExceptionObject & e)
    {
 std::cerr << "exception in file reader " << std::endl;
 std::cerr << e << std::endl;
 //          return EXIT_FAILURE;
    }
 InputImageType::Pointer image_1 = reader->GetOutput() ;
 // the image parameters
 unsigned long lwidth = image_1->GetLargestPossibleRegion().GetSize()[0] ;
 unsigned long lheight = image_1->GetLargestPossibleRegion().GetSize()[1] ;
 InputImageType::IndexType index;
 index[0]=1;
index[1]=1;

 signed short pixel_value;
 pixel_value= image_1->GetPixel( index );
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101228/51a70fa0/attachment.htm>


More information about the Insight-users mailing list