NewOne
NewOne

Reputation: 19

Can't get Pixel Data from DICOM using GDCM

I need some help with GDCM.

I've been trying to get the Pixel Data from DICOM file for a few days. There are lot's of ways how to do it... I decided to use GDCM. I download their libraries and try to get pixel data like this:

#include "gdcmFileHelper.h"
#include "gdcmFile.h"

int main( int argc, char* argv[] )
{
   gdcm::File *f1 = new gdcm::File();
   f1->SetFileName( 'test.dcm' );
   f1->Load();   
   gdcm::FileHelper *fh = gdcm::FileHelper::New(f1);
   unsigned int *imageData = fh->GetImageDataRaw();
   unsigned int imageDatasize = fh->GGetImageDataRawSize();
   return 0;
}  

But, I have no gdcmFileHelper.h in their list of headers and lib's ... So I've tried like this:

#include "gdcmImageReader.h"
#include "gdcmImage.h"

int main(int argc, char *argv[])
{
  gdcm::ImageReader reader;
  reader.SetFileName( filename );
  const gdcm::Image &image = reader.GetImage();
  return 0;
}

How can i get pixel data in this way ? Or .. where can i get gdcmFileHelper.h...

Upvotes: 0

Views: 3977

Answers (1)

malat
malat

Reputation: 12506

You have to call image.GetBuffer(), see for example the PIL <-> GDCM binding:

ConvertPIL.py

You first example will not work, it uses GDCM 1.x, which has been abandoned AFAIK.

Upvotes: 1

Related Questions