コード例 #1
0
 public override void Encode(
     DicomPixelData oldPixelData,
     DicomPixelData newPixelData,
     DicomCodecParams parameters)
 {
     DicomRleNativeCodec.Encode(oldPixelData.ToNativePixelData(), newPixelData.ToNativePixelData());
 }
コード例 #2
0
        public override void Encode(
            DicomPixelData oldPixelData,
            DicomPixelData newPixelData,
            DicomCodecParams parameters)
        {
            if (oldPixelData.NumberOfFrames == 0) return;

            // IJG eats the extra padding bits. Is there a better way to test for this?
            if (oldPixelData.BitsAllocated == 16 && oldPixelData.BitsStored <= 8)
            {
                // check for embedded overlays?
                newPixelData.BitsAllocated = 8;
            }

            var jparams = parameters as DicomJpegParams ?? GetDefaultParameters() as DicomJpegParams;

            var codec = GetCodec(oldPixelData.BitsStored, jparams);

            var oldNativeData = oldPixelData.ToNativePixelData();
            var newNativeData = newPixelData.ToNativePixelData();
            var jNativeParams = jparams.ToNativeJpegParameters();
            for (var frame = 0; frame < oldPixelData.NumberOfFrames; frame++)
            {
                codec.Encode(oldNativeData, newNativeData, jNativeParams, frame);
            }
        }
コード例 #3
0
        public override void Encode(
            DicomPixelData oldPixelData,
            DicomPixelData newPixelData,
            DicomCodecParams parameters)
        {
            if (oldPixelData.NumberOfFrames == 0)
            {
                return;
            }

            // IJG eats the extra padding bits. Is there a better way to test for this?
            if (oldPixelData.BitsAllocated == 16 && oldPixelData.BitsStored <= 8)
            {
                // check for embedded overlays?
                newPixelData.BitsAllocated = 8;
            }

            var jparams = parameters as DicomJpegParams ?? GetDefaultParameters() as DicomJpegParams;

            var codec = GetCodec(oldPixelData.BitsStored, jparams);

            var oldNativeData = oldPixelData.ToNativePixelData();
            var newNativeData = newPixelData.ToNativePixelData();
            var jNativeParams = jparams.ToNativeJpegParameters();

            for (var frame = 0; frame < oldPixelData.NumberOfFrames; frame++)
            {
                codec.Encode(oldNativeData, newNativeData, jNativeParams, frame);
            }
        }
コード例 #4
0
ファイル: DicomRleCodecImpl.cs プロジェクト: aerik/fo-dicom
 public override void Encode(
     DicomPixelData oldPixelData,
     DicomPixelData newPixelData,
     DicomCodecParams parameters)
 {
     DicomRleNativeCodec.Encode(oldPixelData.ToNativePixelData(), newPixelData.ToNativePixelData());
 }
コード例 #5
0
 public override void Decode(
     DicomPixelData oldPixelData,
     DicomPixelData newPixelData,
     DicomCodecParams parameters)
 {
     DicomJpegLsNativeCodec.Decode(
         oldPixelData.ToNativePixelData(),
         newPixelData.ToNativePixelData(),
         parameters.ToNativeJpegLSParameters());
 }
コード例 #6
0
 public override void Encode(
     DicomPixelData oldPixelData,
     DicomPixelData newPixelData,
     DicomCodecParams parameters)
 {
     DicomJpeg2000NativeCodec.Encode(
         oldPixelData.ToNativePixelData(),
         newPixelData.ToNativePixelData(),
         parameters.ToNativeJpeg2000Parameters());
 }
コード例 #7
0
 public override void Decode(
     DicomPixelData oldPixelData,
     DicomPixelData newPixelData,
     DicomCodecParams parameters)
 {
     DicomJpegLsNativeCodec.Decode(
         oldPixelData.ToNativePixelData(),
         newPixelData.ToNativePixelData(),
         parameters.ToNativeJpegLSParameters());
 }
コード例 #8
0
 public override void Encode(
     DicomPixelData oldPixelData,
     DicomPixelData newPixelData,
     DicomCodecParams parameters)
 {
     DicomJpeg2000NativeCodec.Encode(
         oldPixelData.ToNativePixelData(),
         newPixelData.ToNativePixelData(),
         parameters.ToNativeJpeg2000Parameters());
 }
コード例 #9
0
        public override void Decode(
            DicomPixelData oldPixelData,
            DicomPixelData newPixelData,
            DicomCodecParams parameters)
        {
            if (oldPixelData.NumberOfFrames == 0)
            {
                return;
            }

            // IJG eats the extra padding bits. Is there a better way to test for this?
            if (newPixelData.BitsAllocated == 16 && newPixelData.BitsStored <= 8)
            {
                // check for embedded overlays here or below?
                newPixelData.BitsAllocated = 8;
            }

            var jparams = parameters as DicomJpegParams ?? GetDefaultParameters() as DicomJpegParams;

            var oldNativeData = oldPixelData.ToNativePixelData();
            int precision;

            try
            {
                try
                {
                    precision = JpegHelper.ScanJpegForBitDepth(oldPixelData);
                }
                catch
                {
                    // if the internal scanner chokes on an image, try again using ijg
                    precision = new Jpeg12Codec(JpegMode.Baseline, 0, 0).ScanHeaderForPrecision(oldNativeData);
                }
            }
            catch
            {
                // the old scanner choked on several valid images...
                // assume the correct encoder was used and let libijg handle the rest
                precision = oldPixelData.BitsStored;
            }

            if (newPixelData.BitsStored <= 8 && precision > 8)
            {
                newPixelData.BitsAllocated = 16;                                                // embedded overlay?
            }
            var codec = GetCodec(precision, jparams);

            var newNativeData = newPixelData.ToNativePixelData();
            var jNativeParams = jparams.ToNativeJpegParameters();

            for (var frame = 0; frame < oldPixelData.NumberOfFrames; frame++)
            {
                codec.Decode(oldNativeData, newNativeData, jNativeParams, frame);
            }
        }
コード例 #10
0
        public override void Encode(
            DicomPixelData oldPixelData,
            DicomPixelData newPixelData,
            DicomCodecParams parameters)
        {
#if NETFX_CORE && !HOLOLENS
            DicomJpeg2000NativeCodec.Encode(
                oldPixelData.ToNativePixelData(),
                newPixelData.ToNativePixelData(),
                parameters.ToNativeJpeg2000Parameters());
#else
            DicomJpeg2000CodecImpl.Encode(oldPixelData, newPixelData, parameters as DicomJpeg2000Params);
#endif
        }
コード例 #11
0
        public override void Encode(
            DicomPixelData oldPixelData,
            DicomPixelData newPixelData,
            DicomCodecParams parameters)
        {
#if NETFX_CORE
            DicomJpeg2000NativeCodec.Encode(
                oldPixelData.ToNativePixelData(),
                newPixelData.ToNativePixelData(),
                parameters.ToNativeJpeg2000Parameters());
#else
            DicomJpeg2000CodecImpl.Encode(oldPixelData, newPixelData, parameters as DicomJpeg2000Params);
#endif
        }
コード例 #12
0
        public override void Decode(
            DicomPixelData oldPixelData,
            DicomPixelData newPixelData,
            DicomCodecParams parameters)
        {
            if (oldPixelData.NumberOfFrames == 0) return;

            // IJG eats the extra padding bits. Is there a better way to test for this?
            if (newPixelData.BitsAllocated == 16 && newPixelData.BitsStored <= 8)
            {
                // check for embedded overlays here or below?
                newPixelData.BitsAllocated = 8;
            }

            var jparams = parameters as DicomJpegParams ?? GetDefaultParameters() as DicomJpegParams;

            var oldNativeData = oldPixelData.ToNativePixelData();
            int precision;
            try
            {
                try
                {
                    precision = JpegHelper.ScanJpegForBitDepth(oldPixelData);
                }
                catch
                {
                    // if the internal scanner chokes on an image, try again using ijg
                    precision = new Jpeg12Codec(JpegMode.Baseline, 0, 0).ScanHeaderForPrecision(oldNativeData);
                }
            }
            catch
            {
                // the old scanner choked on several valid images...
                // assume the correct encoder was used and let libijg handle the rest
                precision = oldPixelData.BitsStored;
            }

            if (newPixelData.BitsStored <= 8 && precision > 8) newPixelData.BitsAllocated = 16; // embedded overlay?

            var codec = GetCodec(precision, jparams);

            var newNativeData = newPixelData.ToNativePixelData();
            var jNativeParams = jparams.ToNativeJpegParameters();
            for (var frame = 0; frame < oldPixelData.NumberOfFrames; frame++)
            {
                codec.Decode(oldNativeData, newNativeData, jNativeParams, frame);
            }
        }