How do I extract pixel data from DICOM files on iOS?


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

Sorry if this is a simple question, but it seems to be a major component to a huge can of worms I have opened.


I'm using GDCM on iOS. I haven't pushed it very hard yet but it's working well so far. I basically followed the directions for hacking XCode projects to run in iOS in this excellent article on <a href="http://www.insight-journal.org/browse/publication/755" rel="nofollow">ITK</a>.

Here's how I got it to compile for iOS:

<ol><li>Downloaded source from sourceforge, installed cmake via ports. You'll need a recent version of cmake (I'm using 2.8.2)</li> <li>If the source is in a folder called gdcm-2.0.17/, then create another directory at that level (say gdcmbin), cd to that directory, and enter <strong>ccmake -GXCode ../gdcm-2.0.17/</strong> in the terminal window. This creates the XCode project. When I did this I didn't create any of the example programs or create shared libraries (which won't work in iOS). Just run the defaults.</li> <li>Follow the directions in the ITK paper on changing the build options (step #7 on page 4).</li> <li>Then link GDCM into your project using the excellent instructions at <a href="http://www.clintharris.net/2009/iphone-app-shared-libraries/" rel="nofollow">Clint Harris' blog</a></li> <li>When you're setting up the header search path in your project to GDCM - you have to enter two paths: <em>blah</em>/gdcm-2.0.17/Source/** and <em>blah</em>/gdcmbin/**. The trailing '/Source' on the first path is necessary - otherwise you get headers that aren't appropriate for your architecture.</li> <li>One glitch (annoying but haven't spent the time to figure it out yet): you get a bunch of linking errors when you switch from simulator to device (or vice versa). This is because the gdcm project doesn't put the outputs into different directories for different targets. So - run a clean and rebuild in the gdcm project when you're switching. I'll probably get annoyed by this soon enough to change it :-).</li> </ol>

Here's a rough snippet of how you'd call the library and put the results in 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 in an *.mm file that mixes C++ and ObjectiveC)


If you want to find DICOM software, look at <a href="http://idoimaging.com" rel="nofollow">idoimaging.com</a>, a clearinghouse for medical imaging software. You can choose your platform, input format, output format, language, etc. iOS isn't listed as a format, but much of the software listed there is available with source, useful in library form, and available for MacOS X. For example, I selected:

<ul><li>input format: DICOM</li> <li>platform: Macintosh</li> <li>language: C</li> </ul>

and found several packages. Given the similarities between MacOS and iOS and the fact that some of these are cross-platform with source included, it shouldn't be too difficult to get one of them working on iOS.


  • Raphaeljs Substring Text attributes
  • multiple iron-collapse not working, expands only first
  • R - Keep log of all plots
  • How to apply a partial derivative Gaussian kernel to an image with OpenCV?
  • Detecting both left and right mouse movement and no movement
  • How can I allow tags through rails 4 sanitize?
  • Does argparse support multiple exclusive arguments?
  • Edit assembly language code in Visual Studio while stepping through each statement
  • Upgrade project from WorkLight 6.1 to MobileFirst 7.1
  • F#: In which memory area is the continuation stored: stack or heap?
  • Primefaces lazy datascroller calling load twice
  • C++ Single function pointer for all template instances
  • Can I have a variable number of URI parameters or key-value pairs in Laravel 4?
  • How to access meteor package name inside package?
  • Rest Services conventions
  • SonarQube: Cannot deactivate rule with missing quality profile
  • Debugging VB6 Code From Visual Studio 2010
  • Webgrid not refreshing after delete MVC
  • Test if a set exists before trying to drop it
  • Jquery UI tool tip close icon
  • Django: Count of Group Elements
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • Deleting and Updating values from a cusrsor adapter
  • Modifying destination and filename of gulp-svg-sprite
  • htaccess rewriting URLs with multiple forward slashes
  • 'TypeError' while using NSGA2 to solve Multi-objective prob. from pyopt-sparse in OpenMDAO
  • Convert array of 8 bytes to signed long in C++
  • Display Images one by one with next and previous functionality
  • Web-crawler for facebook in python
  • R: gsub and capture
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Traverse Array and Display in markup
  • Comma separated Values
  • A cron job substitute?
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • -fvisibility=hidden not passed by compiler for Debug builds
  • Qt: Run a script BEFORE make
  • Net Present Value in Excel for Grouped Recurring CF
  • How to load view controller without button in storyboard?