How to extract pixel data from DICOM files in iOS?

Does anyone know how I can extract pixel data from a DICOM file and feed it to an iOS image viewer?

Sorry if this is a simple question, but it seems to be the main component of the huge jar of worms I discovered.

+2


source to share


2 answers


I am using GDCM for iOS. I haven't pushed it very hard yet, but so far it works well. I've mostly followed the instructions on how to hack Xcode projects to run on iOS in this great ITK article .

This is how I got it to compile for iOS:

  • Downloaded source from sourceforge installed by cmake via ports. You will need the latest version of cmake (I am using 2.8.2)
  • If the source is in a folder named gdcm-2.0.17 /, then create another directory at that level (say gdcmbin), cd in that directory and type ccmake -GXCode ../ gdcm-2.0. 17 / in a terminal window. This creates an Xcode project. When I did this, I did not create any of the sample programs or create shared libraries (which will not work on iOS). Just run the default settings.
  • Follow the directions in the ITK document for changing build parameters (step # 7 on page 4).
  • Then connect GDCM to your project using the excellent instructions on Clint Harris's blog
  • When you set up the title search path in your GDCM project, you need to enter two paths: blah / gdcm-2.0.17 / Source / ** and blah / gdcmbin / **. The final "/ Source" in the first path is required - otherwise you will end up with headers that are not appropriate for your architecture.
  • One glitch (annoying, but haven't taken the time to figure it out yet): you get a bunch of communication errors when switching from simulator to device (or vice versa). This is because the gdcm project does not output output to different directories for different purposes. So, run a cleanup and rebuild your gdcm project at switch time. I will probably get annoyed by this soon enough to change it :-).


Here's a rough snippet of how you would name the library and put the results into an Objective-C dictionary:

NSMutableDictionary * imageDictionary = [[NSMutableDictionary alloc] initWithCapacity:40];
// The output of gdcm::Reader is a gdcm::File
gdcm::File &file = reader.GetFile();

// the dataset is the the set of element we are interested in:
gdcm::DataSet &ds = file.GetDataSet();
const Tag studyInstance(0x0020,0x000d); // Study Instance UID
const DataElement &dicomVal = ds.GetDataElement(studyInstance);
std::string stringVal( dicomVal.GetByteValue()->GetPointer(), dicomVal.GetByteValue()->GetLength() );
NSString *val = [NSString stringWithCString:stringVal.c_str() encoding:[NSString defaultCStringEncoding]];
[imageDictionary setObject:val forKey:@"studyInstanceUID"];

      

(Note: this is a * .mm file that mixes C ++ and ObjectiveC)

+5


source


If you want to find DICOM software, check out idoimaging.com , the clearing house for medical imaging software. You can choose platform, input format, output format, language, etc. IOS is not displayed as a format, but most of the software listed there is available with source code useful as a library and available for MacOS X. For example, I chose:

  • input format: DICOM Platform
  • : Macintosh
  • language: C


and found some packages. Given the similarities between macOS and iOS, and the fact that some of them are source-enabled cross-platform, it shouldn't be too hard to get one of them to work on iOS.

0


source







All Articles