示例#1
0
 protected void CreatePixelDataItem()
 {
     _frames = 0;
     if (IsEncapsulated)
     {
         _pixelDataItem = new DcmFragmentSequence(DicomTags.PixelData, DicomVR.OB);
     }
     else
     {
         if (!TransferSyntax.IsExplicitVR || (_bitsAllocated > 8 && _bitsAllocated <= 16))
         {
             _pixelDataItem = new DcmOtherWord(DicomTags.PixelData);
         }
         else
         {
             _pixelDataItem = new DcmOtherByte(DicomTags.PixelData);
         }
     }
 }
示例#2
0
        public DcmPixelData(DcmDataset dataset)
        {
            _transferSyntax            = dataset.InternalTransferSyntax;
            _lossy                     = dataset.GetString(DicomTags.LossyImageCompression, "00") != "00";
            _lossyMethod               = dataset.GetString(DicomTags.LossyImageCompressionMethod, String.Empty);
            _lossyRatio                = dataset.GetString(DicomTags.LossyImageCompressionRatio, String.Empty);
            _frames                    = dataset.GetInt32(DicomTags.NumberOfFrames, 1);
            _width                     = dataset.GetUInt16(DicomTags.Columns, 0);
            _height                    = dataset.GetUInt16(DicomTags.Rows, 0);
            _bitsStored                = dataset.GetUInt16(DicomTags.BitsStored, 0);
            _bitsAllocated             = dataset.GetUInt16(DicomTags.BitsAllocated, 0);
            _highBit                   = dataset.GetUInt16(DicomTags.HighBit, (ushort)(_bitsStored - 1));
            _samplesPerPixel           = dataset.GetUInt16(DicomTags.SamplesPerPixel, 0);
            _pixelRepresentation       = dataset.GetUInt16(DicomTags.PixelRepresentation, 0);
            _planarConfiguration       = dataset.GetUInt16(DicomTags.PlanarConfiguration, 0);
            _photometricInterpretation = dataset.GetString(DicomTags.PhotometricInterpretation, String.Empty);
            _rescaleSlope              = dataset.GetDouble(DicomTags.RescaleSlope, 1.0);
            _rescaleIntercept          = dataset.GetDouble(DicomTags.RescaleIntercept, 0.0);
            _pixelDataItem             = dataset.GetItem(DicomTags.PixelData);

            _hasPixelPadding = dataset.Contains(DicomTags.PixelPaddingValue);
            if (_hasPixelPadding)
            {
                DcmElement elem = dataset.GetElement(DicomTags.PixelPaddingValue);
                if (elem is DcmUnsignedShort && elem.GetVM() > 0)
                {
                    _pixelPaddingValue = (elem as DcmUnsignedShort).GetValue();
                }
                else if (elem is DcmSignedShort && elem.GetVM() > 0)
                {
                    _pixelPaddingValue = (elem as DcmSignedShort).GetValue();
                }
                else
                {
                    _pixelPaddingValue = MinimumDataValue;
                }
            }
        }
示例#3
0
 public void AddItem(DcmItem item)
 {
     _items.Remove(item.Tag);
     _items.Add(item.Tag, item);
     item.Endian = InternalTransferSyntax.Endian;
 }
示例#4
0
 public DicomNode(Image image, DcmItem elem)
     : base()
 {
     _image = image;
     _elem = elem;
 }
示例#5
0
        private void InsertDatasetItem(DcmItem item, DicomReadOptions options)
        {
            if (_sds.Count > 0 && _sds.Count == _sqs.Count) {
                DcmDataset ds = _sds.Peek();

                if (_tag.Element == 0x0000) {
                    if (Flags.IsSet(options, DicomReadOptions.KeepGroupLengths))
                        ds.AddItem(item);
                }
                else
                    ds.AddItem(item);

                if (ds.StreamLength != UndefinedLength) {
                    long end = ds.StreamPosition + ds.StreamLength;
                    if ((_stream.Position - _offset) >= end)
                        _sds.Pop();
                }
            }
            else {
                if (_tag.Element == 0x0000) {
                    if (Flags.IsSet(options, DicomReadOptions.KeepGroupLengths))
                        _dataset.AddItem(item);
                }
                else
                    _dataset.AddItem(item);
            }

            if (_tag == DicomTags.SpecificCharacterSet && item is DcmCodeString) {
                DcmCodeString cs = (DcmCodeString)item;
                if (cs.Length > 0) {
                    string[] values = cs.GetValues();
                    for (int i = 0; i < values.Length; i++) {
                        if (String.IsNullOrEmpty(values[i]))
                            continue;
                        _encoding = DcmEncoding.GetEncodingForSpecificCharacterSet(values[i]);
                        break;
                    }
                }
            }
        }
示例#6
0
		public DcmPixelData(DcmDataset dataset) {
			_transferSyntax = dataset.InternalTransferSyntax;
			_lossy = dataset.GetString(DicomTags.LossyImageCompression, "00") != "00";
			_lossyMethod = dataset.GetString(DicomTags.LossyImageCompressionMethod, String.Empty);
			_lossyRatio = dataset.GetString(DicomTags.LossyImageCompressionRatio, String.Empty);
			_frames = dataset.GetInt32(DicomTags.NumberOfFrames, 1);
			_width = dataset.GetUInt16(DicomTags.Columns, 0);
			_height = dataset.GetUInt16(DicomTags.Rows, 0);
			_bitsStored = dataset.GetUInt16(DicomTags.BitsStored, 0);
			_bitsAllocated = dataset.GetUInt16(DicomTags.BitsAllocated, 0);
			_highBit = dataset.GetUInt16(DicomTags.HighBit, (ushort)(_bitsStored - 1));
			_samplesPerPixel = dataset.GetUInt16(DicomTags.SamplesPerPixel, 0);
			_pixelRepresentation = dataset.GetUInt16(DicomTags.PixelRepresentation, 0);
			_planarConfiguration = dataset.GetUInt16(DicomTags.PlanarConfiguration, 0);
			_photometricInterpretation = dataset.GetString(DicomTags.PhotometricInterpretation, String.Empty);
			_rescaleSlope = dataset.GetDouble(DicomTags.RescaleSlope, 1.0);
			_rescaleIntercept = dataset.GetDouble(DicomTags.RescaleIntercept, 0.0);
			_pixelDataItem = dataset.GetItem(DicomTags.PixelData);

			_hasPixelPadding = dataset.Contains(DicomTags.PixelPaddingValue);
			if (_hasPixelPadding) {
				DcmElement elem = dataset.GetElement(DicomTags.PixelPaddingValue);
				if (elem is DcmUnsignedShort)
					_pixelPaddingValue = (elem as DcmUnsignedShort).GetValue();
				else if (elem is DcmSignedShort) {
					_pixelPaddingValue = (elem as DcmSignedShort).GetValue();
				} else
					_pixelPaddingValue = MinimumDataValue;
			}
		}
示例#7
0
		protected void CreatePixelDataItem() {
			_frames = 0;
			if (IsEncapsulated) {
				_pixelDataItem = new DcmFragmentSequence(DicomTags.PixelData, DicomVR.OB);
			}
			else {
				if (!TransferSyntax.IsExplicitVR || (_bitsAllocated > 8 && _bitsAllocated <= 16))
					_pixelDataItem = new DcmOtherWord(DicomTags.PixelData);
				else
					_pixelDataItem = new DcmOtherByte(DicomTags.PixelData);
			}
		}