I want to create app in which .dcm images are open in ios. can anyone tell me how to open .dcm images in ios app.its like a images viewer that only open .dcm images. You anyone have any idea about it ??? your help should be appreciated. thanks,
dcmtk can also be built for ios. I have tested some sample apps and ported my own build to ios. Also, you can just build your own dicom parser. You can open .dcm files like any other file on a computer and process the bytes with your own code. The DICOM spec is freely available online.
The C++ Dicom library Imebra can be compiled on iOS and referenced from Objective-C applications.
Few Objective-C helpers can convert std::wstring to/from NSString and from Imebra Image classes to UIImage or NSSimage.
All the files referencing the Imebra library must have the extension .mm (mixed C++/ObjectiveC, opposed to the single .m for pure Objective-C files).
Opening a file:
using namespace puntoexe;
ptr<stream> readStream(new stream());
readStream->openFile(NSStringToStringW(@"d:\\test.dcm"), std::ios::in);
Reading the Dicom dataset:
ptr<streamReader> reader(new streamReader(readStream));
ptr<imebra::dataSet> testDataSet = imebra::codecs::codecFactory::getCodecFactory()->load(reader);
Getting the first image
ptr<imebra::image> firstImage = testDataSet->getModalityImage(0);
Transforming the image into UIImage
UIImage* iosIMage = getImage(firstImage, ptr<imebra::transforms::transform>(0));
Getting the patient's name:
NSString* patientNameCharacter = StringWToNSString(testDataSet->getString(0x0010, 0, 0x0010, 0));
NSString* patientNameIdeographic = StringWToNSString(testDataSet->getString(0x0010, 0, 0x0010, 1));
UPDATE
The code above is for a legacy version of Imebra.
Imebra V4 has a slightly different API (detailed explanation):
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);
UPDATE 2
Imebra now comes with Objective-C wrappers that can also be parsed by the Swift compiler.
来源:https://stackoverflow.com/questions/34612127/how-to-open-dcm-images-in-ios-app-using-objective-c