0

DICOM - Digital Imaging and Communications in Medicine, is a standard for handling, storing, printing, and transmitting information in medical imaging. It includes a file format definition and a network communications protocol.

I want to write .dcm file in my ios Project. Please suggest me any link.

Deepak Kumar
  • 1,035
  • 10
  • 18

1 Answers1

2

Update: Imebra 4.2 includes the full set of ObjectiveC wrappers, which also work with Swift.

Original alswer: Imebra allows to read and generate DICOM files also on iOS.

It compiles also for iOS and OS-X, it's written in C++ but it can be used with ObjectiveC method if the extension of the file is .mm instead of .m

Since version 4.0.8.1, Imebra contains also few objectiveC helpers that translate C++ strings to NSStrings (and vice-versa) and extract an UIImage (or NSImage) from an Imebra image

How to generate a DICOM file in Imebra (detailed instructions):

Create an empty dataset:

// We specify the transfer syntax and the charset
std::string transferSyntax(imebra::NSStringToString(@"1.2.840.10008.1.2.1"));
std::string encoding(imebra::NSStringToString(@"ISO 2022 IR 6"));
imebra::DataSet dataSet(transferSyntax, encoding);

Create an image, put it into the dataset:

// Create a 300 by 200 pixel image, 15 bits per color channel, RGB
std::string colorSpace(imebra::NSStringToString(@"RGB"));
imebra::Image image(300, 200, imebra::bitDepth_t::depthU16, colorSpace, 15);

{
    std::unique_ptr<WritingDataHandlerNumeric> dataHandler(image.getWritingDataHandler());

    // Set all the pixels to red
    for(std::uint32_t scanY(0); scanY != 200; ++scanY)
    {
        for(std::uint32_t scanX(0); scanX != 300; ++scanX)
        {
            dataHandler->setUnsignedLong((scanY * 300 + scanX) * 3, 65535);
            dataHandler->setUnsignedLong((scanY * 300 + scanX) * 3 + 1, 0);
            dataHandler->setUnsignedLong((scanY * 300 + scanX) * 3 + 2, 0);
        }
    }

    // dataHandler will go out of scope and will commit the data into the image
}

dataSet.setImage(0, image);

Save the dataset

std::string fileName(NSStringToString(@"path/to/file.dcm"));
imebra::CodecFactory::save(dataSet, fileName, imebra::codecType_t::dicom);

(disclusure: I'm the author of Imebra)

Paolo Brandoli
  • 4,681
  • 26
  • 38
  • how to use Imebra with Xcode , what step should use to build imebra in iOS project ? – Deepak Kumar Jan 17 '17 at 09:23
  • @DeepakKumar Documentation: https://imebra.com/wp-content/uploads/documentation/html/compiling_imebra.html#os-x-ios-specific-instructions – Paolo Brandoli Jan 17 '17 at 09:26
  • according to your documentation of imebra for iOS , i successfully build imebra through cmake, Now what step should follow ,thanks – Deepak Kumar Jan 17 '17 at 10:46
  • after cmake build i get `libimebra.a` and also i add this lib into my project but when i import or include `imebra/imebra.h` , `can't found imebra/imebra.h` – Deepak Kumar Jan 17 '17 at 11:17
  • Add the library/include folder to the include path http://stackoverflow.com/questions/14134064/how-to-set-include-path-in-xcode-project – Paolo Brandoli Jan 17 '17 at 12:07
  • thanks paolo but now it gives me, `Undefined symbols for architecture x86_64: "_iconv", referenced from: imebra::charsetConversionIconv::myIconv(void*, char*, unsigned long) const in libimebra.a(charsetConversionIconvImpl.cpp.o) clang: error: linker command failed with exit code 1 (use -v to see invocation)` – Deepak Kumar Jan 17 '17 at 12:28
  • @PaoloBrandoli can imebra be used in swift as well? Its documentation is little tough to understand – Apogee Sep 11 '17 at 05:10
  • @Apogee Imebra can be used only from Objective-C. An Objective-C to Swift bridge has to be written in order to use Imebra with Swift – Paolo Brandoli Sep 11 '17 at 09:03
  • @PaoloBrandoli You mean I would have to create an interface in objective C between my SWIFT code and Imebra? Can you please elaborate your comment. I know dicom integration is a vast subject but if you could explain me then it will be really helpful. I know whats bridging but I don't have idea about such two level bridging: Imebra(C++) -> Obj C -> Swift – Apogee Sep 11 '17 at 09:15
  • 1
    @Apogee Swift code can call methods on classes written in ObjectiveC (see here https://stackoverflow.com/questions/24002369/how-to-call-objective-c-code-from-swift) while ObjectiveC code can call methods written in C++. Since Swift cannot call directly C++ code then for all the needed C++ classes a ObjectiveC class must be written: The ObjectiveC class would just call the counterpart C++ code and return – Paolo Brandoli Sep 11 '17 at 09:37
  • Got it. Thanks alot @PaoloBrandoli – Apogee Sep 11 '17 at 09:46