コード例 #1
0
 /// <summary>
 /// Checks if this module appears to be non-empty.
 /// </summary>
 /// <returns>True if the module appears to be non-empty; False otherwise.</returns>
 public virtual bool HasValues()
 {
     return(DefinedTags.Any(t =>
     {
         DicomAttribute a;
         return DicomAttributeProvider.TryGetAttribute(t, out a) && !a.IsEmpty;
     }));
 }
コード例 #2
0
ファイル: OverlayPlane.cs プロジェクト: hksonngan/Xian
        // TODO (CR May 2011): Doesn't feel 100% like this method belongs here,
        // but it doesn't quite fit into DicomPixelData either, which is probably where it should go.

        /// <summary>
        /// Extracts all overlays embedded in pixel data and populates the <see cref="DicomTags.OverlayData"/> attribute.
        /// </summary>
        /// <returns>True if any overlays were actually extracted, otherwise false.</returns>
        /// <remarks>Certain restrictions apply to the use of this method:
        /// <list type="bullet">
        /// <item><see cref="IodBase.DicomAttributeProvider"/> must be a <see cref="DicomAttributeCollection"/>.</item>
        /// <item>The <see cref="DicomTags.PixelData"/> attribute must not contain encapsulated pixel data.
        /// Check the <see cref="TransferSyntax"/> of the source message before calling this method.</item>
        /// </list>
        /// </remarks>
        public bool ExtractEmbeddedOverlays()
        {
            var collection = base.DicomAttributeProvider as DicomAttributeCollection;

            if (collection == null)
            {
                throw new ArgumentException("Module must wrap a DicomAttributeCollection in order to extract overlays.");
            }

            DicomAttribute attribute;

            if (!DicomAttributeProvider.TryGetAttribute(DicomTags.PixelData, out attribute))
            {
                Platform.Log(LogLevel.Debug, "Sop does not appear to have any pixel data from which to extract embedded overlays.");
                return(false);
            }

            if (attribute is DicomFragmentSequence)
            {
                Platform.Log(LogLevel.Debug, "Sop pixel data must be uncompressed to extract overlays.");
                return(false);
            }

            if (attribute.IsNull)
            {
                Platform.Log(LogLevel.Debug, "Sop pixel data has no valid value and cannot have embedded overlays extracted.");
                return(false);
            }

            var  pixelData    = new DicomUncompressedPixelData(collection);
            bool anyExtracted = false;

            // Check if Overlay is embedded in pixels
            foreach (var overlay in this)
            {
                if (overlay.HasOverlayData)
                {
                    continue;
                }

                Platform.Log(LogLevel.Debug, "SOP Instance has embedded overlay in pixel data, extracting");
                overlay.ExtractEmbeddedOverlay(pixelData);
                anyExtracted = true;
            }

            return(anyExtracted);
        }
コード例 #3
0
 public bool TryGetAttribute(DicomTag tag, out DicomAttribute attribute)
 {
     return(DicomAttributeProvider.TryGetAttribute(tag, out attribute));
 }