Search code examples
iosipaddicomitk

ITK library on iOS - Loading DICOM


I have built the ITK library for the ipad - and it works. Then I tried to make an ITK example - something like that:

// Load DICOM files
typedef itk::ImageSeriesReader< InputImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
typedef itk::GDCMImageIO ImageIOType;
typedef itk::GDCMSeriesFileNames NamesGeneratorType;
ImageIOType::Pointer gdcmIO = ImageIOType::New();
NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
namesGenerator->SetInputDirectory( "C:/test" );

But I tried a lot of possibilites to load a DICOM stack in a directory on the documents folder of the ipad instead of the c:/test path. But that didn't work.

So my idea is to load a DICOM like that over the internet:

NSData *dicomImage = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.someurl.ch/dicom/blabla.dcm"]];   

And now I think about trying to get out the dicom data (patient name etc) and separate it from the image data. Then I think it must be possible to have at the end an UIImage to display on the IPAD.

I searched for an example for that, but sadly...i didnt found something good. If anybody has got an idea how to load a dcm on the ipad through ITK or an idea how to get the image data out of the NSData object?


Solution

  • ITK actually uses GDCM to read DICOM files, so it's probably easier to use GDCM directly. http://sourceforge.net/apps/mediawiki/gdcm/index.php

    As for loading DICOM files on the iPad (or any mobile device), I would be careful when doing so. Some DICOM files are very large (on the order of GBs), and that would probably just crash your application. Of course, you'd probably have a difficult time loading files that large onto the iPad anyway :)


    The pixel data is not necessarily RGB data as you would expect to find in a JPEG. Check the photometric interpretation. If it's RGB, then you're good to go (after decoding & decompression). If it's monochrome, you may need to convert to RGB values (see How to translate DICOM image width and level to JPEG brightness and contrast?) before passing the data to UIImage.