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


C# DicomDataset.FirstOrDefault方法代码示例

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


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

示例1: Load

		private void Load(DicomDataset ds) {
			_rows = ds.Get<ushort>(OverlayTag(DicomTag.OverlayRows));
			_columns = ds.Get<ushort>(OverlayTag(DicomTag.OverlayColumns));
			
			var type = ds.Get<string>(OverlayTag(DicomTag.OverlayType), "Unknown");
			if (type.StartsWith("R"))
				_type = DicomOverlayType.ROI;
			else
				_type = DicomOverlayType.Graphics;

			DicomTag tag = OverlayTag(DicomTag.OverlayOrigin);
			if (ds.Contains(tag)) {
				_originX = ds.Get<short>(tag, 0, 1);
				_originY = ds.Get<short>(tag, 1, 1);
			}

			_bitsAllocated = ds.Get<ushort>(OverlayTag(DicomTag.OverlayBitsAllocated), 0, 1);
			_bitPosition = ds.Get<ushort>(OverlayTag(DicomTag.OverlayBitPosition), 0, 0);

			tag = OverlayTag(DicomTag.OverlayData);
			if (ds.Contains(tag)) {
				var elem = ds.FirstOrDefault(x => x.Tag == tag) as DicomElement;
				_data = elem.Buffer;
			} else {
				// overlay embedded in high bits of pixel data
				if (ds.InternalTransferSyntax.IsEncapsulated)
					throw new DicomImagingException("Attempted to extract embedded overlay from compressed pixel data. Decompress pixel data before attempting this operation.");

				var pixels = DicomPixelData.Create(ds);

				// (1,1) indicates top left pixel of image
				int ox = Math.Max(0, _originX - 1);
				int oy = Math.Max(0, _originY - 1);
				int ow = Math.Min(_rows, pixels.Width - _rows - ox);
				int oh = Math.Min(_columns, pixels.Height - _columns - oy);

				var frame = pixels.GetFrame(0);

				// calculate length of output buffer
				var count = (_rows * _columns) / 8;
				if (((_rows * _columns) % 8) != 0)
					count++;
				if ((count & 1) != 0)
					count++;

				var bytes = new byte[count];
				var bits = new BitArray(bytes);
				int mask = 1 << _bitPosition;

				if (pixels.BitsAllocated == 8) {
					var data = ByteBufferEnumerator<byte>.Create(frame).ToArray();

					for (int y = oy; y < oh; y++) {
						int n = (y * pixels.Width) + ox;
						int i = (y - oy) * _columns;
						for (int x = ox; x < ow; x++) {
							if ((data[n] & mask) != 0)
								bits[i] = true;
							n++;
							i++;
						}
					}
				} else if (pixels.BitsAllocated == 16) {
					// we don't really care if the pixel data is signed or not
					var data = ByteBufferEnumerator<ushort>.Create(frame).ToArray();

					for (int y = oy; y < oh; y++) {
						int n = (y * pixels.Width) + ox;
						int i = (y - oy) * _columns;
						for (int x = ox; x < ow; x++) {
							if ((data[n] & mask) != 0)
								bits[i] = true;
							n++;
							i++;
						}
					}
				} else {
					throw new DicomImagingException("Unable to extract embedded overlay from pixel data with bits stored greater than 16.");
				}

				_data = new MemoryByteBuffer(bytes);
			}

			_description = ds.Get<string>(OverlayTag(DicomTag.OverlayDescription), String.Empty);
			_subtype = ds.Get<string>(OverlayTag(DicomTag.OverlaySubtype), String.Empty);
			_label = ds.Get<string>(OverlayTag(DicomTag.OverlayLabel), String.Empty);

			_frames = ds.Get<int>(OverlayTag(DicomTag.NumberOfFramesInOverlay), 0, 1);
			_frameOrigin = ds.Get<ushort>(OverlayTag(DicomTag.ImageFrameOrigin), 0, 1);

			//TODO: include ROI
		}
开发者ID:vvboborykin,项目名称:DicomStorage,代码行数:92,代码来源:DicomOverlayData.cs

示例2: CreateRecordSequenceItem

		private DicomDirectoryRecord CreateRecordSequenceItem(DicomDirectoryRecordType recordType, DicomDataset dataset) {
			if (recordType == null)
				throw new ArgumentNullException("recordType");
			if (dataset == null)
				throw new ArgumentNullException("dataset");

			var sequenceItem = new DicomDirectoryRecord();

			//add record item attributes
			sequenceItem.Add<uint>(DicomTag.OffsetOfTheNextDirectoryRecord, 0);
			sequenceItem.Add<ushort>(DicomTag.RecordInUseFlag, 0xFFFF);
			sequenceItem.Add<uint>(DicomTag.OffsetOfReferencedLowerLevelDirectoryEntity, 0);
			sequenceItem.Add<string>(DicomTag.DirectoryRecordType, recordType.ToString());

			//copy the current dataset character set
			sequenceItem.Add(dataset.FirstOrDefault(d => d.Tag == DicomTag.SpecificCharacterSet));

			foreach (var tag in recordType.Tags) {
				if (dataset.Contains(tag)) {
					sequenceItem.Add(dataset.Get<DicomItem>(tag));
				} else {
					System.Diagnostics.Debug.WriteLine("Cannot find tag {0} for record type {1}", tag, recordType);
				}
			}

			return sequenceItem;
		}
开发者ID:ZeryZhang,项目名称:fo-dicom,代码行数:27,代码来源:DicomDirectory.cs

示例3: Load

        private void Load(DicomDataset ds)
        {
            _rows = ds.Get<ushort>(OverlayTag(DicomTag.OverlayRows));
            _columns = ds.Get<ushort>(OverlayTag(DicomTag.OverlayColumns));
            _type = ds.Get<string>(OverlayTag(DicomTag.OverlayType), "Unknown");

            DicomTag tag = OverlayTag(DicomTag.OverlayOrigin);
            if (ds.Contains(tag)) {
                short[] xy = ds.Get<short[]>(tag);
                if (xy != null && xy.Length == 2) {
                    _originX = xy[0];
                    _originY = xy[1];
                }
            }

            _bitsAllocated = ds.Get<ushort>(OverlayTag(DicomTag.OverlayBitsAllocated), 0, 1);
            _bitPosition = ds.Get<ushort>(OverlayTag(DicomTag.OverlayBitPosition), 0, 0);

            tag = OverlayTag(DicomTag.OverlayData);
            if (ds.Contains(tag)) {
                var elem = ds.FirstOrDefault(x => x.Tag == tag) as DicomElement;
                _data = elem.Buffer;
            }

            _description = ds.Get<string>(OverlayTag(DicomTag.OverlayDescription), String.Empty);
            _subtype = ds.Get<string>(OverlayTag(DicomTag.OverlaySubtype), String.Empty);
            _label = ds.Get<string>(OverlayTag(DicomTag.OverlayLabel), String.Empty);

            _frames = ds.Get<int>(OverlayTag(DicomTag.NumberOfFramesInOverlay), 0, 1);
            _frameOrigin = ds.Get<ushort>(OverlayTag(DicomTag.ImageFrameOrigin), 0, 1);

            //TODO: include ROI
        }
开发者ID:jwake,项目名称:fo-dicom,代码行数:33,代码来源:DicomOverlayData.cs


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