如何从iOS上的DICOM文件中提取像素数据? [英] How do I extract pixel data from DICOM files on iOS?

查看:618
本文介绍了如何从iOS上的DICOM文件中提取像素数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何从DICOM文件中提取像素数据并将其传递给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.

推荐答案

我在iOS上使用GDCM。我还没有非常努力地推动它,但到目前为止它还运行良好。我基本上按照关于 ITK

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 ITK.

以下是我为iOS编译的方法:

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


  1. 从sourceforge下载源,通过端口安装cmake。你需要一个最新版本的cmake(我正在使用2.8.2)

  2. 如果源是在一个名为gdcm-2.0.17 /的文件夹中,那么在那个位置创建另一个目录等级(比如gdcmbin),cd到该目录,然后在终端窗口中输入 ccmake -GXCode ../ gdcm-2.0.17 / 。这将创建XCode项目。当我这样做时,我没有创建任何示例程序或创建共享库(这在iOS中不起作用)。只需运行默认值。

  3. 按照ITK文章中有关更改构建选项的说明(第4页上的步骤#7)。

  4. 然后链接GDCM使用 Clint Harris'博客中的优秀说明进入您的项目/ li>
  5. 当您在项目中将标题搜索路径设置为GDCM时 - 您必须输入两个路径: blah /gdcm-2.0.17/Source/ **和 blah / gdcmbin / **。第一条路径上的尾随'/ Source'是必要的 - 否则你会得到不适合你的架构的标题。

  6. 一个小故障(烦人但没有花时间去计算它还是):当你从模拟器切换到设备时,你会得到一堆链接错误(反之亦然)。这是因为gdcm项目不会将输出放入不同目标的不同目录中。所以 - 当你切换时,在gdcm项目中运行一个干净和重建。我可能很快就会对此感到恼火,以便改变它: - )。

  1. Downloaded source from sourceforge, installed cmake via ports. You'll need a recent version of cmake (I'm using 2.8.2)
  2. 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 ccmake -GXCode ../gdcm-2.0.17/ 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.
  3. Follow the directions in the ITK paper on changing the build options (step #7 on page 4).
  4. Then link GDCM into your project using the excellent instructions at Clint Harris' blog
  5. When you're setting up the header search path in your project to GDCM - you have to enter two paths: blah/gdcm-2.0.17/Source/** and blah/gdcmbin/**. The trailing '/Source' on the first path is necessary - otherwise you get headers that aren't appropriate for your architecture.
  6. 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 :-).

这是你如何调用的粗略片段该库并将结果放在Objective-C字典中:

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"];

(注意:这是一个混合了C ++和ObjectiveC的* .mm文件)

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

这篇关于如何从iOS上的DICOM文件中提取像素数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆