SetCompressedPixelFile

In DicomObjects.NET (version 6 onwards), encapsulating or simply importing compressed data (e.g. MP4 video file) into DICOM is made possible by the SetCompressedPixelFile method which maps an external file as the compressed pixel data of that DicomImage instance.  Unlike the import method, this ONLY sets the pixel data itself, so you need to set all the associated values (bit depth, frame count etc.) yourself.

Example code with dummy values :

            int width = 1280;    

            int height=720;      

            int frameRate=25;               // 25 frames per seconds for example

            float duration = 5;                // 5 seconds the total duration of video, for example

            string transferSyntax = "1.2.840.10008.1.2.4.XX";     // .103 for mp4

            DicomImage img = new DicomImage();

            img.SetCompressedPixelFile(MP4_filename, 0, transferSyntax);

 

            // the following attributes are set according to DICOM Standard MPEG-4 requirements:

            img.DataSet.Add(Keyword.PlanarConfiguration, 0);

            img.DataSet.Add(Keyword.SamplesPerPixel, 3);

            img.DataSet.Add(Keyword.PhotometricInterpretation, "YBR_PARTIAL_420");

            img.DataSet.Add(Keyword.BitsAllocated, 8);

            img.DataSet.Add(Keyword.BitsStored, 8);

            img.DataSet.Add(Keyword.HighBit, 7);

            img.DataSet.Add(Keyword.PixelRepresentation, 0);

            img.DataSet.Add(Keyword.CineRate, frameRate);

            img.DataSet.Add(Keyword.Rows, height);

            img.DataSet.Add(Keyword.Columns, width);

            img.DataSet.Add(Keyword.NumberOfFrames, (int)(frameRate * duration));

            img.SOPClass = DicomObjects.DicomUIDs.SOPClasses.SecondaryCapture;       //   appropriate SOP Class required 

            img.InstanceUID = DicomGlobal.NewUID();           

 

            // Add other DICOM attributes like name, dob, sex study Instance UID, series Instance UID etc, to make a valid DICOM instance, according to the specified SOP Class UID.

            // follow this link to see the list of DICOM attributes that are required to make valid DICOM secondary capture sop class instance: http://www.medicalconnections.co.uk/kb/Creating_Secondary_Capture_Images