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


C# DicomDataset.Contains方法代码示例

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


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

示例1: FromDataset

        public static GrayscaleRenderOptions FromDataset(DicomDataset dataset)
        {
            var bits = BitDepth.FromDataset(dataset);
            var options = new GrayscaleRenderOptions(bits);
            options.RescaleSlope = dataset.Get<double>(DicomTag.RescaleSlope, 1.0);
            options.RescaleIntercept = dataset.Get<double>(DicomTag.RescaleIntercept, 0.0);
            if (dataset.Contains(DicomTag.WindowWidth) && dataset.Get<double>(DicomTag.WindowWidth) != 0.0) {
                options.WindowWidth = dataset.Get<double>(DicomTag.WindowWidth);
                options.WindowCenter = dataset.Get<double>(DicomTag.WindowCenter);
            } else if (dataset.Contains(DicomTag.SmallestImagePixelValue) && dataset.Contains(DicomTag.LargestImagePixelValue)) {
                var smallElement = dataset.Get<DicomElement>(DicomTag.SmallestImagePixelValue);
                var largeElement = dataset.Get<DicomElement>(DicomTag.LargestImagePixelValue);

                int smallValue = 0;
                int largeValue = 0;

                if (smallElement.ValueRepresentation == DicomVR.US) {
                    smallValue = smallElement.Get<ushort>(0);
                    largeValue = smallElement.Get<ushort>(0);
                } else {
                    smallValue = smallElement.Get<short>(0);
                    largeValue = smallElement.Get<short>(0);
                }

                options.WindowWidth = largeValue - smallValue;
                options.WindowCenter = (largeValue + smallValue) / 2.0;
            }
            options.Monochrome1 = dataset.Get<PhotometricInterpretation>(DicomTag.PhotometricInterpretation) == PhotometricInterpretation.Monochrome1;
            return options;
        }
开发者ID:jwake,项目名称:fo-dicom,代码行数:30,代码来源:GrayscaleRenderOptions.cs

示例2: Contains_PrivateTag_SufficientlyFound

 public void Contains_PrivateTag_SufficientlyFound()
 {
     var dataset = new DicomDataset();
     dataset.Add(new DicomTag(0x0021, 0x0010, "TEST"), "TEST");
     var found = dataset.Contains(new DicomTag(0x0021, 0x0010, "TEST"));
     Assert.True(found);
 }
开发者ID:aerik,项目名称:fo-dicom,代码行数:7,代码来源:GH319.cs

示例3: FromBitmap

        /// <summary>
        /// Creates a DICOM overlay from a GDI+ Bitmap.
        /// </summary>
        /// <param name="ds">Dataset</param>
        /// <param name="bitmap">Bitmap</param>
        /// <param name="mask">Color mask for overlay</param>
        /// <returns>DICOM overlay</returns>
        public static DicomOverlayData FromBitmap(DicomDataset ds, Bitmap bitmap, Color mask)
        {
            ushort group = 0x6000;
            while (ds.Contains(new DicomTag(group, DicomTag.OverlayBitPosition.Element))) group += 2;

            var overlay = new DicomOverlayData(ds, group)
                              {
                                  Type = DicomOverlayType.Graphics,
                                  Rows = bitmap.Height,
                                  Columns = bitmap.Width,
                                  OriginX = 1,
                                  OriginY = 1,
                                  BitsAllocated = 1,
                                  BitPosition = 1
                              };

            var array = new BitList { Capacity = overlay.Rows * overlay.Columns };

            int p = 0;
            for (var y = 0; y < bitmap.Height; y++)
            {
                for (var x = 0; x < bitmap.Width; x++, p++)
                {
                    if (bitmap.GetPixel(x, y).ToArgb() == mask.ToArgb()) array[p] = true;
                }
            }

            overlay.Data = EvenLengthBuffer.Create(new MemoryByteBuffer(array.Array));

            return overlay;
        }
开发者ID:gustavosaita,项目名称:fo-dicom,代码行数:38,代码来源:DicomOverlayDataFactory.cs

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

示例5: Contains_SamePrivateTagsDifferentPrivateCreator_ReturnsTrue

 public void Contains_SamePrivateTagsDifferentPrivateCreator_ReturnsTrue()
 {
     var dataset = new DicomDataset { new DicomUnknown(new DicomTag(0x3005, 0x3025, "PRIVATE")) };
     Assert.True(dataset.Contains(new DicomTag(0x3005, 0x1525, "PRIVATE")));
 }
开发者ID:aerik,项目名称:fo-dicom,代码行数:5,代码来源:DicomTagTest.cs

示例6: Match

		public bool Match(DicomDataset dataset) {
			if (dataset.Contains(_tag)) {
				var value = dataset.Get<string>(_tag, -1, String.Empty);
				return value.Wildcard(_pattern);
			}
			return false;
		}
开发者ID:vvboborykin,项目名称:DicomStorage,代码行数:7,代码来源:DicomMatchRules.cs

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

示例8: ProcessOverlays

        private static void ProcessOverlays(DicomDataset input, DicomDataset output)
        {
            var overlays = DicomOverlayData.FromDataset(input.InternalTransferSyntax.IsEncapsulated ? output : input);

            foreach (var overlay in overlays)
            {
                var dataTag = new DicomTag(overlay.Group, DicomTag.OverlayData.Element);

                // Don't run conversion on non-embedded overlays.
                if (output.Contains(dataTag)) continue;

                // If embedded overlay, Overlay Bits Allocated should equal Bits Allocated (#110).
                var bitsAlloc = output.Get(DicomTag.BitsAllocated, (ushort)0);
                output.AddOrUpdate(new DicomTag(overlay.Group, DicomTag.OverlayBitsAllocated.Element), bitsAlloc);

                var data = overlay.Data;
                if (output.InternalTransferSyntax.IsExplicitVR) output.AddOrUpdate(new DicomOtherByte(dataTag, data));
                else output.AddOrUpdate(new DicomOtherWord(dataTag, data));
            }
        }
开发者ID:aerik,项目名称:fo-dicom,代码行数:20,代码来源:DicomTranscoder.cs

示例9: Transform

		public void Transform(DicomDataset dataset, DicomDataset modifiedAttributesSequenceItem = null) {
			if (dataset.Contains(_tag)) {
				dataset.CopyTo(modifiedAttributesSequenceItem, _tag);
				var value = dataset.Get<string>(_tag, -1, String.Empty);
				if (_position == DicomTrimPosition.Both) {
					if (_trim != null)
						value = value.Trim(_trim);
					else
						value = value.Trim();
				} else if (_position == DicomTrimPosition.Start) {
					if (_trim != null)
						value = value.TrimStart(_trim);
					else
						value = value.TrimStart();
				} else {
					if (_trim != null)
						value = value.TrimEnd(_trim);
					else
						value = value.TrimEnd();
				}
				dataset.Add(_tag, value);
			}
		}
开发者ID:ZeryZhang,项目名称:fo-dicom,代码行数:23,代码来源:DicomTransformRules.cs

示例10: ContainsPrivateTagsChangesNothingWhenPresent

        public void ContainsPrivateTagsChangesNothingWhenPresent()
        {
            DicomPrivateCreator privateCreator = DicomDictionary.Default.GetPrivateCreator("TESTCREATOR");
            DicomDictionary privDict = DicomDictionary.Default[privateCreator];

            var privTag = new DicomDictionaryEntry(DicomMaskedTag.Parse("0011", "xx10"), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.DT);

            privDict.Add(privTag);

            var dataSet = new DicomDataset
            {
                {DicomTag.SOPInstanceUID, "2.999.1241"},
                {DicomTag.SOPClassUID, "2.999.1242"},
                {privTag.Tag, "19700101123456"}
            };

            var dataBefore = SerializeDicom_(dataSet);

            var val = dataSet.Contains(privTag.Tag);

            var dataAfter = SerializeDicom_(dataSet);

            Assert.Equal(dataBefore, dataAfter);
            Assert.True(val);
        }
开发者ID:raysearchlabs,项目名称:fo-dicom,代码行数:25,代码来源:DicomDatasetTest.cs

示例11: HasEmbeddedOverlays

        public static bool HasEmbeddedOverlays(DicomDataset ds)
        {
            var groups = new List<ushort>();
            groups.AddRange(
                ds.Where(x => x.Tag.Group >= 0x6000 && x.Tag.Group <= 0x60FF && x.Tag.Element == 0x0010)
                    .Select(x => x.Tag.Group));

            foreach (var group in groups)
            {
                if (!ds.Contains(new DicomTag(group, DicomTag.OverlayData.Element))) return true;
            }

            return false;
        }
开发者ID:GMZ,项目名称:fo-dicom,代码行数:14,代码来源:DicomOverlayData.cs

示例12: Transcode

		public DicomDataset Transcode(DicomDataset dataset) {
			if (!dataset.Contains(DicomTag.PixelData)) {
				var newDataset = dataset.Clone();
				newDataset.InternalTransferSyntax = OutputSyntax;
				newDataset.RecalculateGroupLengths(false);
				return newDataset;
			}

			if (!InputSyntax.IsEncapsulated && !OutputSyntax.IsEncapsulated) {
				// transcode from uncompressed to uncompressed
				var newDataset = dataset.Clone();
				newDataset.InternalTransferSyntax = OutputSyntax;

				var oldPixelData = DicomPixelData.Create(dataset, false);
				var newPixelData = DicomPixelData.Create(newDataset, true);

				for (int i = 0; i < oldPixelData.NumberOfFrames; i++) {
					var frame = oldPixelData.GetFrame(i);
					newPixelData.AddFrame(frame);
				}

				ProcessOverlays(dataset, newDataset);

				newDataset.RecalculateGroupLengths(false);

				return newDataset;
			}

			if (InputSyntax.IsEncapsulated && OutputSyntax.IsEncapsulated) {
				// transcode from compressed to compressed
				var temp = Decode(dataset, DicomTransferSyntax.ExplicitVRLittleEndian, InputCodec, InputCodecParams);
				return Encode(temp, OutputSyntax, OutputCodec, OutputCodecParams);
			}

			if (InputSyntax.IsEncapsulated) {
				// transcode from compressed to uncompressed
				return Decode(dataset, OutputSyntax, InputCodec, InputCodecParams);
			}

			if (OutputSyntax.IsEncapsulated) {
				// transcode from uncompressed to compressed
				return Encode(dataset, OutputSyntax, OutputCodec, OutputCodecParams);
			}

			throw new DicomCodecException("Unable to find transcoding solution for {0} to {1}", InputSyntax.UID.Name, OutputSyntax.UID.Name);
		}
开发者ID:EdwardMarcus,项目名称:fo-dicom,代码行数:46,代码来源:DicomTranscoder.cs

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

示例14: FromDataset

        /// <summary>
        /// Create <see cref="GrayscaleRenderOptions"/>  from <paramref name="dataset"/> and populate the options properties with values:
        /// Bit Depth
        /// Rescale Slope
        /// Rescale Intercept
        /// Window Width
        /// Window Center
        /// </summary>
        /// <param name="dataset">Dataset to extract <see cref="GrayscaleRenderOptions"/> from</param>
        /// <returns>New grayscale render options instance</returns>
        public static GrayscaleRenderOptions FromDataset(DicomDataset dataset)
        {
            if (dataset.Contains(DicomTag.WindowWidth) && dataset.Get<double>(DicomTag.WindowWidth) >= 1.0
                && dataset.Contains(DicomTag.WindowCenter))
            {
                //If dataset contains WindowWidth and WindowCenter valid attributes used initially for the grayscale options
                return FromWindowLevel(dataset);
            }

            if (dataset.Contains(DicomTag.SmallestImagePixelValue) && dataset.Contains(DicomTag.LargestImagePixelValue)
                && dataset.Get<int>(DicomTag.SmallestImagePixelValue)
                < dataset.Get<int>(DicomTag.LargestImagePixelValue))
            {
                //If dataset contains valid SmallesImagePixelValue and LargesImagePixelValue attributes, use range to calculate
                //WindowWidth and WindowCenter
                return FromImagePixelValueTags(dataset);
            }

            //If reached here, minimum and maximum pixel values calculated from pixels data to calculate
            //WindowWidth and WindowCenter
            return FromMinMax(dataset);
        }
开发者ID:gustavosaita,项目名称:fo-dicom,代码行数:32,代码来源:GrayscaleRenderOptions.cs

示例15: ProcessOverlays

		private static void ProcessOverlays(DicomDataset input, DicomDataset output) {
			DicomOverlayData[] overlays = null;
			if (input.InternalTransferSyntax.IsEncapsulated)
				overlays = DicomOverlayData.FromDataset(output);
			else
				overlays = DicomOverlayData.FromDataset(input);

			foreach (var overlay in overlays) {
				var dataTag = new DicomTag(overlay.Group, DicomTag.OverlayData.Element);

				// don't run conversion on non-embedded overlays
				if (output.Contains(dataTag))
					continue;

				output.Add(new DicomTag(overlay.Group, DicomTag.OverlayBitsAllocated.Element), (ushort)1);
				output.Add(new DicomTag(overlay.Group, DicomTag.OverlayBitPosition.Element), (ushort)0);

				var data = overlay.Data;
				if (output.InternalTransferSyntax.IsExplicitVR)
					output.Add(new DicomOtherByte(dataTag, data));
				else
					output.Add(new DicomOtherWord(dataTag, data));
			}
		}
开发者ID:1danielcoelho,项目名称:FellowOakDicomTesting,代码行数:24,代码来源:DicomTranscoder.cs


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