• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DicomUncompressedPixelData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DicomUncompressedPixelData的典型用法代码示例。如果您正苦于以下问题:C# DicomUncompressedPixelData类的具体用法?C# DicomUncompressedPixelData怎么用?C# DicomUncompressedPixelData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: ChangeSyntax

		public void ChangeSyntax(TransferSyntax syntax)
		{
			try
			{
				if (!_dicomFile.TransferSyntax.Encapsulated)
				{
					// Check if Overlay is embedded in pixels
					OverlayPlaneModuleIod overlayIod = new OverlayPlaneModuleIod(_dicomFile.DataSet);
					for (int i = 0; i < 16; i++)
					{
						if (overlayIod.HasOverlayPlane(i))
						{
							OverlayPlane overlay = overlayIod[i];
							if (overlay.OverlayData == null)
							{
								DicomUncompressedPixelData pd = new DicomUncompressedPixelData(_dicomFile);
								overlay.ConvertEmbeddedOverlay(pd);	
							}
						}
					}
				}
				else if (syntax.Encapsulated)
				{
					// Must decompress first.
					_dicomFile.ChangeTransferSyntax(TransferSyntax.ExplicitVrLittleEndian);
				}

				_dicomFile.ChangeTransferSyntax(syntax);
			}
			catch (Exception e)
			{
				Platform.Log(LogLevel.Error, e, "Unexpected exception compressing/decompressing DICOM file");
			}
		}
开发者ID:nhannd,项目名称:Xian,代码行数:34,代码来源:Compression.cs


示例2: DecodeFrame

		public void DecodeFrame(int frame, DicomCompressedPixelData oldPixelData, DicomUncompressedPixelData newPixelData, DicomCodecParameters parameters)
		{
			using (var input = new MemoryStream(oldPixelData.GetFrameFragmentData(frame)))
			using (var gzipStream = new GZipStream(input, CompressionMode.Decompress, false))
			{
				var data = new byte[oldPixelData.UncompressedFrameSize];
				gzipStream.Read(data, 0, data.Length);
				newPixelData.AppendFrame(data);
			}
		}
开发者ID:kevinpig,项目名称:MyRepository,代码行数:10,代码来源:GZipDicomCodec.cs


示例3: SetupMRWithOverlay

        public void SetupMRWithOverlay(DicomAttributeCollection theSet)
        {
            SetupMR(theSet);

            OverlayPlaneModuleIod overlayIod = new OverlayPlaneModuleIod(theSet);
            DicomUncompressedPixelData pd = new DicomUncompressedPixelData(theSet);
            OverlayPlane overlay = overlayIod[0];

            // Embedded overlays are retired in dicom, just doing it for testing purposes
            theSet[DicomTags.OverlayBitPosition].SetInt32(0, pd.HighBit + 1);
            overlay.OverlayBitsAllocated = 1;
            overlay.OverlayColumns = pd.ImageWidth;
            overlay.OverlayRows = pd.ImageHeight;
            overlay.OverlayOrigin = new Point(0, 0);
            overlay.OverlayType = OverlayType.R;
        }
开发者ID:khaha2210,项目名称:radio,代码行数:16,代码来源:AbstractCodecTest.cs


示例4: DecodeFrame

		public void DecodeFrame(int frame, DicomCompressedPixelData oldPixelData, DicomUncompressedPixelData newPixelData, DicomCodecParameters parameters)
		{
			if (oldPixelData.UncompressedFrameSize%2 == 1)
			{
				using (var stream = new MemoryStream(oldPixelData.GetFrameFragmentData(frame)))
				{
					var data = new byte[oldPixelData.UncompressedFrameSize];
					stream.Read(data, 0, data.Length);
					newPixelData.AppendFrame(data);
				}
			}
			else
			{
				newPixelData.AppendFrame(oldPixelData.GetFrameFragmentData(frame));
			}
		}
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:16,代码来源:NullDicomCodec.cs


示例5: 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


示例6: SetupEncapsulatedImageWithIconSequence

		private void SetupEncapsulatedImageWithIconSequence(DicomFile file, bool encapsulateIconPixelData)
		{
			var codec = new NullDicomCodec();

			DicomAttributeCollection dataSet = file.DataSet;

			SetupSecondaryCapture(dataSet);

			SetupMetaInfo(file);

			file.TransferSyntax = TransferSyntax.ImplicitVrLittleEndian;
			file.ChangeTransferSyntax(codec.CodecTransferSyntax);

			// explicitly create the icon sequence as either encapsulated or native, so that we are not depending on correct behaviour elsewhere...
			CreateIconImageSequence(dataSet);

			if (encapsulateIconPixelData)
			{
				var dataset = ((DicomAttributeSQ) dataSet[DicomTags.IconImageSequence])[0];
				var pixelData = dataset[DicomTags.PixelData];

				var pd = new DicomUncompressedPixelData(dataset);
				using (var pixelStream = ((DicomAttributeBinary) pixelData).AsStream())
				{
					//Before compression, make the pixel data more "typical", so it's harder to mess up the codecs.
					//NOTE: Could combine mask and align into one method so we're not iterating twice, but I prefer having the methods separate.
					if (DicomUncompressedPixelData.RightAlign(pixelStream, pd.BitsAllocated, pd.BitsStored, pd.HighBit))
					{
						var newHighBit = (ushort) (pd.HighBit - pd.LowBit);

						pd.HighBit = newHighBit; //correct high bit after right-aligning.
						dataset[DicomTags.HighBit].SetUInt16(0, newHighBit);
					}
					DicomUncompressedPixelData.ZeroUnusedBits(pixelStream, pd.BitsAllocated, pd.BitsStored, pd.HighBit);
				}

				// Set transfer syntax before compression, the codecs need it.
				var fragments = new DicomCompressedPixelData(pd) {TransferSyntax = codec.CodecTransferSyntax};
				codec.Encode(pd, fragments, null);
				fragments.UpdateAttributeCollection(dataset);
			}
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:42,代码来源:IconImageSequenceTests.cs


示例7: 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


示例8: 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


示例9: 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


示例10: DecodeFrame

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

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

            int pixelCount = oldPixelData.ImageWidth * oldPixelData.ImageHeight;
            int numberOfSegments = oldPixelData.BytesAllocated * oldPixelData.SamplesPerPixel;
            int segmentLength = (pixelCount & 1) == 1 ? pixelCount + 1 : pixelCount;

            byte[] segment = new byte[segmentLength];
            byte[] frameData = new byte[oldPixelData.UncompressedFrameSize];

            IList<DicomFragment> rleData = oldPixelData.GetFrameFragments(frame);
            RLEDecoder decoder = new RLEDecoder(rleData);

            if (decoder.NumberOfSegments != numberOfSegments)
                throw new DicomCodecException("Unexpected number of RLE segments!");

            for (int s = 0; s < numberOfSegments; s++)
            {
                decoder.DecodeSegment(s, segment);

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

                int pos;
                int offset;

                if (newPixelData.PlanarConfiguration == 0)
                {
                    pos = sample * oldPixelData.BytesAllocated;
                    offset = oldPixelData.SamplesPerPixel * oldPixelData.BytesAllocated;
                }
                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++)
                {
                    frameData[pos] = segment[p];
                    pos += offset;
                }
            }

            newPixelData.AppendFrame(frameData);
        }
开发者ID:scottshea,项目名称:monodicom,代码行数:56,代码来源:DicomRleCodec.cs


示例11: 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


示例12: 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


示例13: CreateColorPixelData

		protected static void CreateColorPixelData(DicomUncompressedPixelData pd)
		{
			int rows = pd.ImageHeight;
			int cols = pd.ImageWidth;

            int minValue = pd.IsSigned ? -(1 << (pd.BitsStored - 1)) : 0;
            int maxValue = (1 << pd.BitsStored) + minValue - 1;
            const byte noOpByteMask = 0xFF;
            var byteMask = (byte)(noOpByteMask >> (pd.BitsAllocated - pd.BitsStored));        

			// Create a small block of pixels in the test pattern in an integer,
			// then copy/tile into the full size frame data

			int smallRows = (rows * 3) / 8;
			int smallColumns = rows / 4;
			int stripSize = rows / 16;

			int[] smallPixels = new int[smallRows * smallColumns * 3];

			float slope = (float)(maxValue - minValue) / smallColumns;

			int pixelOffset = 0;
			for (int i = 0; i < smallRows; i++)
			{
				if (i < stripSize)
				{
					for (int j = 0; j < smallColumns; j++)
					{
						smallPixels[pixelOffset] = (int)((j * slope) + minValue);
						pixelOffset++;
						smallPixels[pixelOffset] = 0;
						pixelOffset++;
						smallPixels[pixelOffset] = 0;
						pixelOffset++;
					}
				}
				else if (i > (smallRows - stripSize))
				{
					for (int j = 0; j < smallColumns; j++)
					{
						smallPixels[pixelOffset] = 0;
						pixelOffset++;
						smallPixels[pixelOffset] = (int)(maxValue - (j * slope));
						pixelOffset++;
						smallPixels[pixelOffset] = 0;
						pixelOffset++;
					}
				}
				else
				{
					int pixel = minValue + (int)((i - stripSize) * slope);
					if (pixel < minValue) pixel = minValue + 1;
					if (pixel > maxValue) pixel = maxValue - 1;

					int start = (smallColumns / 2) - (i - stripSize) / 2;
					int end = (smallColumns / 2) + (i - stripSize) / 2;

					for (int j = 0; j < smallColumns; j++)
					{
						smallPixels[pixelOffset] = 0;
						pixelOffset++;
						smallPixels[pixelOffset] = 0;
						pixelOffset++;
						if (j < start)
							smallPixels[pixelOffset] = minValue;
						else if (j > end)
							smallPixels[pixelOffset] = maxValue;
						else
							smallPixels[pixelOffset] = pixel;

						pixelOffset++;
					}
				}
			}
			// Now create the actual frame
			for (int frame = 0; frame < pd.NumberOfFrames; frame++)
			{
				// Odd length frames are automatically dealt with by DicomUncompressedPixelData
				byte[] frameData = new byte[pd.UncompressedFrameSize];
				pixelOffset = 0;

				for (int i = 0; i < rows; i++)
				{
					int smallOffset = (i%smallRows)*smallColumns*3;

					for (int j = 0; j < cols*3; j++)
					{
						frameData[pixelOffset] = (byte) smallPixels[smallOffset + j%(smallColumns*3)];
					    frameData[pixelOffset] &= byteMask;
						pixelOffset++;
					}
				}

				pd.AppendFrame(frameData);
			}
		}
开发者ID:emmandeb,项目名称:ClearCanvas-1,代码行数:96,代码来源:AbstractTest.cs


示例14: Convert8BitSigned

        public static int[] Convert8BitSigned(byte[] byteInputData, int pixels, DicomUncompressedPixelData pd)
        {
            int shiftBits = 32 - pd.BitsStored;
            bool bPixelRescale = !string.IsNullOrEmpty(pd.RescaleSlope) &&
                                                      !string.IsNullOrEmpty(pd.RescaleIntercept)
                                                      &&
                                                      (pd.DecimalRescaleSlope != 1m ||
                                                       pd.DecimalRescaleIntercept != 0m);
            byte pixelMask = 0x00;
            for (int x = 0; x < pd.BitsStored; x++)
                pixelMask = (byte)((pixelMask << 1) | 0x0001);

            int[] intPixels = new int[pixels];
            for (int pixelCount = 0; pixelCount < byteInputData.Length; pixelCount++)
            {
                intPixels[pixelCount] = byteInputData[pixelCount] & pixelMask;

                intPixels[pixelCount] = (((intPixels[pixelCount] << shiftBits)) >> shiftBits);

                if (bPixelRescale)
                    intPixels[pixelCount] = intPixels[pixelCount] * (int)pd.DecimalRescaleSlope +
                                    (int)pd.DecimalRescaleIntercept;
            }
            return intPixels;
        }
开发者ID:nhannd,项目名称:Xian,代码行数:25,代码来源:AbstractCodecTest.cs


示例15: CreatePixelData

 protected static void CreatePixelData(DicomAttributeCollection dataSet)
 {
     dataSet[DicomTags.PixelData] = null;
     var pd = new DicomUncompressedPixelData(dataSet);
     CreatePixelData(pd);
     pd.UpdateAttributeCollection(dataSet);
 }
开发者ID:emmandeb,项目名称:ClearCanvas-1,代码行数:7,代码来源:AbstractTest.cs


示例16: 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


示例17: CreateFile

		public DicomFile CreateFile(ushort rows, ushort columns, string photometricInterpretation, ushort bitsStored, ushort bitsAllocated, bool isSigned, ushort numberOfFrames)
		{
			DicomFile file = new DicomFile("SCTestImage.dcm");

			DicomAttributeCollection dataSet = file.DataSet;

			SetupSecondaryCapture(dataSet);

			dataSet[DicomTags.PixelData] = null;

			DicomUncompressedPixelData pd = new DicomUncompressedPixelData(dataSet)
			                                	{
			                                		ImageWidth = columns,
			                                		ImageHeight = rows,
			                                		PhotometricInterpretation = photometricInterpretation,
			                                		BitsAllocated = bitsAllocated,
			                                		BitsStored = bitsStored,
			                                		HighBit = (ushort) (bitsStored - 1),
			                                		PixelRepresentation = (ushort) (isSigned ? 1 : 0),
			                                		NumberOfFrames = numberOfFrames
			                                	};

            CreatePixelData(pd);
            pd.UpdateAttributeCollection(dataSet);

			SetupMetaInfo(file);

			file.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian;

			return file;
		}
开发者ID:emmandeb,项目名称:ClearCanvas-1,代码行数:31,代码来源:AbstractTest.cs


示例18: PartialFrameTest

        public void PartialFrameTest()
        {
            DicomFile file = new DicomFile("RlePartialFrameTest.dcm");

            SetupMultiframeXA(file.DataSet, 511, 511, 7);

            file.ChangeTransferSyntax(TransferSyntax.RleLossless);

            file.Save();

            DicomFile newFile = new DicomFile(file.Filename);

            newFile.Load(DicomReadOptions.StorePixelDataReferences);

            DicomPixelData pd;

            if (!newFile.TransferSyntax.Encapsulated)
                pd = new DicomUncompressedPixelData(newFile);
            else if (newFile.TransferSyntax.Equals(TransferSyntax.RleLossless))
                pd = new DicomCompressedPixelData(newFile);
            else
                throw new DicomCodecException("Unsupported transfer syntax: " + newFile.TransferSyntax);

            for (int i=0; i< pd.NumberOfFrames; i++)
            {
                pd.GetFrame(i);
            }
        }
开发者ID:nhannd,项目名称:Xian,代码行数:28,代码来源:CodecTest.cs


示例19: Convert16BitSigned

        public static int[] Convert16BitSigned(byte[] byteInputData, int pixels, DicomUncompressedPixelData pd)
        {
            int shiftBits = 32 - pd.BitsStored;

            int[] intPixels = new int[pixels];
            for (int byteArrayCount = 0, pixelCount = 0;
                 byteArrayCount < byteInputData.Length;
                 byteArrayCount += 2, pixelCount++)
            {
                intPixels[pixelCount] = BitConverter.ToInt16(byteInputData, byteArrayCount);

                intPixels[pixelCount] = (intPixels[pixelCount] << shiftBits) >> shiftBits;
            }

            return intPixels;
        }
开发者ID:nhannd,项目名称:Xian,代码行数:16,代码来源:AbstractCodecTest.cs


示例20: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Dict类代码示例发布时间:2022-05-24
下一篇:
C# DicomTag类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap