Encode JPG image file as DICOM PixelData using ClearCanvas

I have a set of JPG images that are actually fragments of computed tomography that I want to restore to DICOM image files and import into PACS.

I use ClearCanvas and installed all the necessary tags (and confirmed them by converting one of my JPG files to DICOM using a proprietary application to make sure they are the same). I'm just not sure how I should process my JPG file to get it in the PixelData tag?

I am currently converting it to an array of bytes, advising the ClearCanvas forums, but the image just gets distorted in the DICOM viewer. How do I process image data to get it in a readable format?

    public DicomFile CreateFileFromImage(Image image)
    {
        int height = image.Height;
        int width = image.Width;
        short bitsPerPixel = (short)Image.GetPixelFormatSize(image.PixelFormat);

        byte[] imageBuffer = ImageToByteArray(image);
        DicomFile dicomFile = new DicomFile();
        dicomFile.DataSet[DicomTags.Columns].SetInt32(0, width);
        dicomFile.DataSet[DicomTags.Rows].SetInt32(0, height);
        dicomFile.DataSet[DicomTags.BitsStored].SetInt16(0, bitsPerPixel);
        dicomFile.DataSet[DicomTags.BitsAllocated].SetInt16(0, bitsPerPixel);
        dicomFile.DataSet[DicomTags.HighBit].SetInt16(0, 7);
        //other tags not shown
        dicomFile.DataSet[DicomTags.PixelData].Values = imageBuffer;
        return dicomFile;
    }
    public static byte[] ImageToByteArray(Image imageIn)
    {
        MemoryStream ms = new MemoryStream();

        imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
        return ms.ToArray();
    }
+2
3

ClearCanvas , DicomFile. DicomCompressedPixelData DicomUncompressedPixelData. DicomFile.

, , DicomCompressedPixelData. . UpdateMessage DicomFile. , AddFrameFragment, . , . , . , .

        short bitsPerPixel = (short)Image.GetPixelFormatSize(image.PixelFormat);

        var dicomFile = new DicomFile();
        var pd = new DicomCompressedPixelData(dicomFile);

        pd.ImageWidth = (ushort)image.Width;
        pd.ImageHeight = (ushort) image.Height;
        pd.BitsStored = (ushort)bitsPerPixel;
        pd.BitsAllocated = (ushort) bitsPerPixel;
        pd.HighBit = 7;
        pd.SamplesPerPixel = 3;
        pd.PlanarConfiguration = 0;
        pd.PhotometricInterpretation = "YBR_FULL_422";

        byte[] imageBuffer = ImageToByteArray(image);
        pd.AddFrameFragment(imageBuffer);

        pd.UpdateMessage(dicomFile);

        return dicomFile;
+1

, :

            int size = rows * columns;
            byte[] pData = new byte[size]; 
            int i = 0;

            for (int row = 0; row < rows; ++row)
            {
                for (int column = 0; column < columns; column++)
                {
                    pData[i++] = image.GetPixel(column, row).R;
                }
            }

, DICOM. DicomCompressedPixelData.

.

0

​​ DICOM JPEG CT. 8- ( JPEG 2) 12- ( JPEG 4) 8, 12 16 ( JPEG 14 - , ). , Pixel Data, Photometric Interpretation, Sample per Pixel, Planer Configuration, Bits Allocated, High Bit to Transfer Syntax.

0