当前位置: 首页>>代码示例>>C#>>正文


C# DicomUncompressedPixelData.GetFrame方法代码示例

本文整理汇总了C#中DicomUncompressedPixelData.GetFrame方法的典型用法代码示例。如果您正苦于以下问题:C# DicomUncompressedPixelData.GetFrame方法的具体用法?C# DicomUncompressedPixelData.GetFrame怎么用?C# DicomUncompressedPixelData.GetFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DicomUncompressedPixelData的用法示例。


在下文中一共展示了DicomUncompressedPixelData.GetFrame方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Encode

		public void Encode(DicomUncompressedPixelData oldPixelData, DicomCompressedPixelData newPixelData, DicomCodecParameters parameters)
		{
			if (oldPixelData.UncompressedFrameSize%2 == 1)
			{
				for (var n = 0; n < oldPixelData.NumberOfFrames; ++n)
				{
					using (var stream = new MemoryStream())
					{
						var data = oldPixelData.GetFrame(n);
						stream.Write(data, 0, data.Length);
						stream.WriteByte(0); // must pad fragments to even length
						newPixelData.AddFrameFragment(stream.ToArray());
					}
				}
			}
			else
			{
				for (var n = 0; n < oldPixelData.NumberOfFrames; ++n)
				{
					newPixelData.AddFrameFragment(oldPixelData.GetFrame(n));
				}
			}
		}
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:23,代码来源:NullDicomCodec.cs

示例2: Encode

		public void Encode(DicomUncompressedPixelData oldPixelData, DicomCompressedPixelData newPixelData, DicomCodecParameters parameters)
		{
			for (var n = 0; n < oldPixelData.NumberOfFrames; ++n)
			{
				using (var output = new MemoryStream())
				{
					using (var gzipStream = new GZipStream(output, CompressionMode.Compress, true))
					{
						var data = oldPixelData.GetFrame(n);
						gzipStream.Write(data, 0, data.Length);
					}

					// if the compressed stream is odd length, append an extra byte - gzip will know that it's padding during decompression
					if (output.Length%2 == 1) output.WriteByte(0);

					newPixelData.AddFrameFragment(output.ToArray());
				}
			}
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:19,代码来源:GZipDicomCodec.cs

示例3: TestBasic_MessageInMemory_8Bits_OB

		public void TestBasic_MessageInMemory_8Bits_OB()
		{
			var dcf = CreateDicomImage(rows : 20, columns : 30, numberOfFrames : 3, bitsAllocated16 : false, useOB : true);
			var pd = new DicomUncompressedPixelData(dcf);

			Assert.AreEqual(8, pd.BitsAllocated, "BitsAllocated");
			Assert.AreEqual(8, pd.BitsStored, "BitsStored");
			Assert.AreEqual(7, pd.HighBit, "HighBit");
			Assert.AreEqual(20, pd.ImageHeight, "ImageHeight");
			Assert.AreEqual(30, pd.ImageWidth, "ImageWidth");
			Assert.AreEqual(3, pd.NumberOfFrames, "NumberOfFrames");
			Assert.AreEqual("MONOCHROME2", pd.PhotometricInterpretation, "PhotometricInterpretation");
			Assert.AreEqual(0, pd.PixelRepresentation, "PixelRepresentation");
			Assert.AreEqual(1, pd.SamplesPerPixel, "SamplesPerPixel");
			Assert.AreEqual(20*30, pd.UncompressedFrameSize, "UncompressedFrameSize");

			for (var frame = 0; frame < 3; ++frame)
			{
				var fd = pd.GetFrame(frame);
				Assert.AreEqual(pd.UncompressedFrameSize, fd.Length, "PixelData(frame={0}).Length", frame);
				AssertBytesEqual((byte) (0x80 + frame), fd, "PixelData(frame={0})", frame);
			}
		}
开发者ID:stevengiblin,项目名称:ClearCanvas,代码行数:23,代码来源:DicomUncompressedPixelDataTests.cs

示例4: TestAdvanced_FileOnDisk_16Bits_OW

		public void TestAdvanced_FileOnDisk_16Bits_OW()
		{
			var filename = Path.GetTempFileName();
			CreateDicomImage(rows : 20, columns : 30, numberOfFrames : 5).Save(filename);

			var dcf = new DicomFile(filename);
			dcf.Load(DicomReadOptions.StorePixelDataReferences);
			try
			{
				var pd = new DicomUncompressedPixelData(dcf);

				Assert.AreEqual(16, pd.BitsAllocated, "BitsAllocated");
				Assert.AreEqual(16, pd.BitsStored, "BitsStored");
				Assert.AreEqual(15, pd.HighBit, "HighBit");
				Assert.AreEqual(20, pd.ImageHeight, "ImageHeight");
				Assert.AreEqual(30, pd.ImageWidth, "ImageWidth");
				Assert.AreEqual(5, pd.NumberOfFrames, "NumberOfFrames");
				Assert.AreEqual("MONOCHROME2", pd.PhotometricInterpretation, "PhotometricInterpretation");
				Assert.AreEqual(0, pd.PixelRepresentation, "PixelRepresentation");
				Assert.AreEqual(1, pd.SamplesPerPixel, "SamplesPerPixel");
				Assert.AreEqual(20*30*2, pd.UncompressedFrameSize, "UncompressedFrameSize");

				var newFrameData = new byte[pd.UncompressedFrameSize];
				for (var n = 0; n < newFrameData.Length; ++n)
					newFrameData[n] = 0x7F;
				pd.SetFrame(1, newFrameData);
				pd.UpdateAttributeCollection(dcf.DataSet);

				var pixelData = dcf.DataSet[DicomTags.PixelData].Values as byte[];
				for (var frame = 0; frame < 5; ++frame)
				{
					var fd = pd.GetFrame(frame);
					var expectedValue = frame == 1 ? (byte) 0x7F : (byte) (0x80 + frame);

					Assert.AreEqual(pd.UncompressedFrameSize, fd.Length, "PixelData(frame={0}).Length", frame);
					AssertBytesEqual(expectedValue, fd, "PixelData(frame={0})", frame);
					AssertBytesEqual(expectedValue, pixelData, frame*pd.UncompressedFrameSize, pd.UncompressedFrameSize, "AttributeValues(frame={0})", frame);
				}
			}
			finally
			{
				File.Delete(filename);
			}
		}
开发者ID:stevengiblin,项目名称:ClearCanvas,代码行数:44,代码来源:DicomUncompressedPixelDataTests.cs

示例5: TestBasic_FileOnDisk_16Bits_BigEndian_OddFrameLength

		public void TestBasic_FileOnDisk_16Bits_BigEndian_OddFrameLength()
		{
			var filename = Path.GetTempFileName();
			CreateDicomImage(rows : 19, columns : 29, numberOfFrames : 5, endian : Endian.Big).Save(filename);

			var dcf = new DicomFile(filename);
			dcf.Load(DicomReadOptions.StorePixelDataReferences);
			try
			{
				var pd = new DicomUncompressedPixelData(dcf);

				Assert.AreEqual(16, pd.BitsAllocated, "BitsAllocated");
				Assert.AreEqual(16, pd.BitsStored, "BitsStored");
				Assert.AreEqual(15, pd.HighBit, "HighBit");
				Assert.AreEqual(19, pd.ImageHeight, "ImageHeight");
				Assert.AreEqual(29, pd.ImageWidth, "ImageWidth");
				Assert.AreEqual(5, pd.NumberOfFrames, "NumberOfFrames");
				Assert.AreEqual("MONOCHROME2", pd.PhotometricInterpretation, "PhotometricInterpretation");
				Assert.AreEqual(0, pd.PixelRepresentation, "PixelRepresentation");
				Assert.AreEqual(1, pd.SamplesPerPixel, "SamplesPerPixel");
				Assert.AreEqual(19*29*2, pd.UncompressedFrameSize, "UncompressedFrameSize");

				for (var frame = 0; frame < 5; ++frame)
				{
					var fd = pd.GetFrame(frame);
					Assert.AreEqual(pd.UncompressedFrameSize, fd.Length, "PixelData(frame={0}).Length", frame);
					AssertBytesEqual((byte) (0x80 + frame), fd, "PixelData(frame={0})", frame);
				}
			}
			finally
			{
				File.Delete(filename);
			}
		}
开发者ID:stevengiblin,项目名称:ClearCanvas,代码行数:34,代码来源:DicomUncompressedPixelDataTests.cs

示例6: TestBasic_FileOnDisk_8Bits_OB

		public void TestBasic_FileOnDisk_8Bits_OB()
		{
			var filename = Path.GetTempFileName();
			CreateDicomImage(rows : 20, columns : 30, numberOfFrames : 3, bitsAllocated16 : false, useOB : true).Save(filename);

			var dcf = new DicomFile(filename);
			dcf.Load(DicomReadOptions.StorePixelDataReferences);
			try
			{
				var pd = new DicomUncompressedPixelData(dcf);

				Assert.AreEqual(8, pd.BitsAllocated, "BitsAllocated");
				Assert.AreEqual(8, pd.BitsStored, "BitsStored");
				Assert.AreEqual(7, pd.HighBit, "HighBit");
				Assert.AreEqual(20, pd.ImageHeight, "ImageHeight");
				Assert.AreEqual(30, pd.ImageWidth, "ImageWidth");
				Assert.AreEqual(3, pd.NumberOfFrames, "NumberOfFrames");
				Assert.AreEqual("MONOCHROME2", pd.PhotometricInterpretation, "PhotometricInterpretation");
				Assert.AreEqual(0, pd.PixelRepresentation, "PixelRepresentation");
				Assert.AreEqual(1, pd.SamplesPerPixel, "SamplesPerPixel");
				Assert.AreEqual(20*30, pd.UncompressedFrameSize, "UncompressedFrameSize");

				for (var frame = 0; frame < 3; ++frame)
				{
					var fd = pd.GetFrame(frame);
					Assert.AreEqual(pd.UncompressedFrameSize, fd.Length, "PixelData(frame={0}).Length", frame);
					AssertBytesEqual((byte) (0x80 + frame), fd, "PixelData(frame={0})", frame);
				}
			}
			finally
			{
				File.Delete(filename);
			}
		}
开发者ID:stevengiblin,项目名称:ClearCanvas,代码行数:34,代码来源:DicomUncompressedPixelDataTests.cs

示例7: CheckPixels

        private void CheckPixels(string filename)
        {
            DicomReadOptions readOptions = DicomReadOptions.StorePixelDataReferences;
            DicomFile newFile = new DicomFile(filename);

            newFile.Load(readOptions);
            DicomUncompressedPixelData pd = new DicomUncompressedPixelData(newFile.DataSet);

            for (int frame = 0; frame < pd.NumberOfFrames; frame++)
            {
                byte[] data = pd.GetFrame(frame);
                uint pdVal = (uint)frame + 1;
                for (int i = 0; i < pd.UncompressedFrameSize; i++, pdVal++)
                {
                    if (data[i] != pdVal%255)
                    {
                        string val = String.Format("Value bad: frame: {0}, pixel: {1}, val1: {2}, val2: {3}", frame, i, data[i], pdVal%255);
                        Console.Write(val);
                    }
                    Assert.AreEqual(data[i], pdVal%255);
                }
            }            
        }
开发者ID:scottshea,项目名称:monodicom,代码行数:23,代码来源:FileTest.cs

示例8: Encode

        public void Encode(DicomUncompressedPixelData oldPixelData, DicomCompressedPixelData newPixelData, DicomCodecParameters parameters)
        {
            DicomRleCodecParameters rleParams = parameters as DicomRleCodecParameters;

            if (rleParams == null)
                throw new DicomCodecException("Unexpected RLE Codec parameters");

			// Convert to RGB
			if (oldPixelData.HasPaletteColorLut && parameters.ConvertPaletteToRGB)
			{
				oldPixelData.ConvertPaletteColorToRgb();
				newPixelData.HasPaletteColorLut = false;
				newPixelData.SamplesPerPixel = oldPixelData.SamplesPerPixel;
				newPixelData.PlanarConfiguration = oldPixelData.PlanarConfiguration;
				newPixelData.PhotometricInterpretation = oldPixelData.PhotometricInterpretation;
			}

        	int pixelCount = oldPixelData.ImageWidth * oldPixelData.ImageHeight;
            int numberOfSegments = oldPixelData.BytesAllocated * oldPixelData.SamplesPerPixel;

            for (int i = 0; i < oldPixelData.NumberOfFrames; i++)
            {
                RLEEncoder encoder = new RLEEncoder();
                byte[] frameData = oldPixelData.GetFrame(i);

                for (int s = 0; s < numberOfSegments; s++)
                {
                    encoder.NextSegment();

                    int sample = s / oldPixelData.BytesAllocated;
                    int sabyte = s % oldPixelData.BytesAllocated;

                    int pos;
                    int offset;

                    if (newPixelData.PlanarConfiguration == 0)
                    {
                        pos = sample * oldPixelData.BytesAllocated;
                        offset = numberOfSegments;
                    }
                    else
                    {
                        pos = sample * oldPixelData.BytesAllocated * pixelCount;
                        offset = oldPixelData.BytesAllocated;
                    }

                    if (rleParams.ReverseByteOrder)
                        pos += sabyte;
                    else
                        pos += oldPixelData.BytesAllocated - sabyte - 1;

                    for (int p = 0; p < pixelCount; p++)
                    {
                        if (pos >= frameData.Length)
                            throw new DicomCodecException("");
                        encoder.Encode(frameData[pos]);
                        pos += offset;
                    }
                    encoder.Flush();
                }

                encoder.MakeEvenLength();

                newPixelData.AddFrameFragment(encoder.GetBuffer());
            }
        }
开发者ID:scottshea,项目名称:monodicom,代码行数:66,代码来源:DicomRleCodec.cs


注:本文中的DicomUncompressedPixelData.GetFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。