/// <summary>
		/// Contructor from a <see cref="DicomCompressedPixelData"/> instance.
		/// </summary>
		/// <param name="compressedPixelData"></param>
		public DicomUncompressedPixelData(DicomCompressedPixelData compressedPixelData)
			: base(compressedPixelData)
		{
			if (BitsAllocated > 8)
			{
				_pd = new DicomAttributeOW(DicomTags.PixelData);
			}
			else
			{
				var pdTag = DicomTagDictionary.GetDicomTag(DicomTags.PixelData);
				var obTag = new DicomTag(DicomTags.PixelData, pdTag.Name, pdTag.VariableName, DicomVr.OBvr, pdTag.MultiVR, pdTag.VMLow, pdTag.VMHigh, pdTag.Retired);
				_pd = new DicomAttributeOB(obTag);
			}
			InitializeFrameData(this, _pd);
		}
		private void InitializeFrameData(DicomUncompressedPixelData owner, DicomAttribute pixelDataAttribute)
		{
			var obAttrib = pixelDataAttribute as DicomAttributeOB;
			if (obAttrib != null && obAttrib.StreamLength > 0)
			{
				for (var n = 0; n < NumberOfFrames; ++n)
					_fd.Add(new FrameDataOB(owner, obAttrib, n));
			}

			var owAttrib = pixelDataAttribute as DicomAttributeOW;
			if (owAttrib != null && owAttrib.StreamLength > 0)
			{
				for (var n = 0; n < NumberOfFrames; ++n)
					_fd.Add(new FrameDataOW(owner, owAttrib, n));
			}
		}
		/// <summary>
		/// Constructor from an <see cref="DicomAttributeCollection"/> instance.
		/// </summary>
		/// <param name="collection"></param>
		public DicomUncompressedPixelData(DicomAttributeCollection collection)
			: base(collection)
		{
			_pd = collection[DicomTags.PixelData];
			InitializeFrameData(this, _pd);
		}
		/// <summary>
		/// Initializes a <see cref="DicomUncompressedPixelData"/> from the attributes in a DICOM file/message.
		/// </summary>
		/// <param name="dicomMessage">A DICOM file/message from which to initialize the properties of the <see cref="DicomUncompressedPixelData"/>.</param>
		public DicomUncompressedPixelData(DicomMessageBase dicomMessage)
			: base(dicomMessage)
		{
			_pd = dicomMessage.DataSet[DicomTags.PixelData];
			InitializeFrameData(this, _pd);
		}
		public void ConvertPaletteColorToRgb()
		{
			Platform.CheckTrue(PhotometricInterpretation.Equals("PALETTE COLOR"), "Photometric Interpretation Palette Color Check");

			List<FrameData> frames = new List<FrameData>();

			for (int i = 0; i < NumberOfFrames; i++)
			{
				byte[] currentFrame = GetFrame(i);
				byte[] newFrame = new byte[UncompressedFrameSize*3];

				PaletteColorToRgb(BitsAllocated, IsSigned, currentFrame, newFrame, PaletteColorLut);
				frames.Add(new FrameDataBytes(this, newFrame, false));
			}

			// change the Pixel Data attribute so we don't affect the original
			_pd = _pd.Tag.VR.CreateDicomAttribute(_pd.Tag);

			_fd.Clear();
			_fd.AddRange(frames);

			SamplesPerPixel = 3;
			PhotometricInterpretation = "RGB";
			PlanarConfiguration = 0;
			HasPaletteColorLut = false;
		}
Пример #6
0
 /// <summary>
 /// Internal constructor used when copying an attribute from a pre-existing attribute instance.
 /// </summary>
 /// <param name="attrib">The attribute that is being copied.</param>
 internal DicomAttribute(DicomAttribute attrib)
 {
     Tag = attrib.Tag;
     _valueCount = attrib.Count;
     _length = attrib.StreamLength;
 }