如何使用Objective C在iOS应用程序中打开.dcm图像

我想创build应用程序,其中.dcm图像打开在iOS中。 谁能告诉我如何在ios app.its中打开.dcm图像,如只能打开.dcm图像的图像查看器。 你有任何想法呢? 应该感激你的帮助。 谢谢,

dcmtk也可以为ios构build。 我已经testing了一些示例应用程序,并将我自己的构build移植到ios。 此外,你可以build立你自己的dicomparsing器。 您可以像打开计算机上的其他文件一样打开.dcm文件,并使用自己的代码处理这些字节。 DICOM规范在线免费提供。

C ++ Dicom库Imebra可以在iOS上编译并从Objective-C应用程序引用。

很less有Objective-C帮助器可以将std :: wstring转换为/从NSString,从Imebra Image类转换为UIImage或NSSimage。

所有引用Imebra库的文件必须具有扩展名.mm(混合的C ++ / ObjectiveC,与纯粹的Objective-C文件中的.m相反)。

打开文件:

using namespace puntoexe; ptr<stream> readStream(new stream()); readStream->openFile(NSStringToStringW(@"d:\\test.dcm"), std::ios::in); 

阅读Dicom数据集:

 ptr<streamReader> reader(new streamReader(readStream)); ptr<imebra::dataSet> testDataSet = imebra::codecs::codecFactory::getCodecFactory()->load(reader); 

获取第一个图像

 ptr<imebra::image> firstImage = testDataSet->getModalityImage(0); 

将图像转换为UIImage

 UIImage* iosIMage = getImage(firstImage, ptr<imebra::transforms::transform>(0)); 

获取患者的姓名:

 NSString* patientNameCharacter = StringWToNSString(testDataSet->getString(0x0010, 0, 0x0010, 0)); NSString* patientNameIdeographic = StringWToNSString(testDataSet->getString(0x0010, 0, 0x0010, 1)); 

UPDATE

上面的代码是Imebra的旧版本。

Imebra V4有一个稍微不同的API( 详细解释 ):

 std::unique_ptr<imebra::DataSet> loadedDataSet(imebra::CodecFactory::load("DicomFile.dcm")); // Retrieve the first image (index = 0) std::unique_ptr<imebra::Image> image(loadedDataSet->getImageApplyModalityTransform(0)); // The transforms chain will contain all the transform that we want to // apply to the image before displaying it imebra::TransformsChain chain; if(imebra::ColorTransformsFactory::isMonochrome(image->getColorSpace()) { // Allocate a VOILUT transform. If the DataSet does not contain any pre-defined // settings then we will find the optimal ones. VOILUT voilutTransform; // Retrieve the VOIs (center/width pairs) imebra::vois_t vois = loadedDataSet->getVOIs(); // Retrieve the LUTs std::list<std::shared_ptr<imebra::LUT> > luts; for(size_t scanLUTs(0); ; ++scanLUTs) { try { luts.push_back(loadedDataSet->getLUT(imebra::TagId(imebra::tagId_t::VOILUTSequence_0028_3010), scanLUTs)); } catch(const imebra::MissingDataElementError&) { break; } } if(!vois.empty()) { voilutTransform.setCenterWidth(vois[0].center, vois[0].width); } else if(!luts.empty()) { voilutTransform.setLUT(*(luts.front().get())); } else { voilutTransform.applyOptimalVOI(image, 0, 0, width, height); } chain.add(voilutTransform); } // If the image is monochromatic then now chain contains the VOILUT transform // We create a DrawBitmap that always apply the chain transform before getting the RGB image imebra::DrawBitmap draw(chain); // Get an NSImage (or UIImage on iOS) UIImage* uiImage = getImebraImage(*ybrImage, draw);