public GetLO ( Dicom.Data.DicomTag tag ) : DcmLongString | ||
tag | Dicom.Data.DicomTag | |
리턴 | DcmLongString |
public static WindowLevel[] FromDataset(DcmDataset dataset) { List<WindowLevel> settings = new List<WindowLevel>(); if (dataset.Contains(DicomTags.WindowCenter) && dataset.Contains(DicomTags.WindowWidth)) { string[] wc = dataset.GetDS(DicomTags.WindowCenter).GetValues(); string[] ww = dataset.GetDS(DicomTags.WindowWidth).GetValues(); if (wc.Length != ww.Length) throw new DicomImagingException("Window Center count does not match Window Width count"); string[] desc = null; if (dataset.Contains(DicomTags.WindowCenterWidthExplanation)) { desc = dataset.GetLO(DicomTags.WindowCenterWidthExplanation).GetValues(); } for (int i = 0; i < wc.Length; i++) { double window; double level; if (!Double.TryParse(ww[i], out window) && !Double.TryParse(ww[i], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out window)) throw new DicomImagingException("Unable to parse Window/Level [ww: {0}]", ww[i]); if (!Double.TryParse(wc[i], out level) && !Double.TryParse(wc[i], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out level)) throw new DicomImagingException("Unable to parse Window/Level [wc: {0}]", wc[i]); string description = String.Empty; if (desc != null && i < desc.Length) description = desc[i]; settings.Add(new WindowLevel(description, window, level)); } } return settings.ToArray(); }