public IEnumerable <double> GetPixelValues(out int realWorldUnits) { realWorldUnits = 0; if (this.PixelData == null) { return(new double[0]); } /// TODO (CR Nov 2011): Why a list rather than yield? List <double> values = new List <double>(); LutFunction lut = v => v; if (this.ModalityLut != null) { lut = v => this.ModalityLut[v]; } Rectangle bounds = GetBoundingBoxRounded(true); for (int x = bounds.Left; x <= bounds.Right; x++) { for (int y = bounds.Top; y <= bounds.Bottom; y++) { PointF p = new PointF(x, y); if (this.Contains(p)) { values.Add(lut(this.PixelData.GetPixel(x, y))); } } } return(values); }
/// <summary> /// Gets an enumeration of the modality LUT transformed pixel values contained within the region of interest. /// </summary> /// <remarks> /// If the <see cref="ModalityLut"/> is null, then this method enumerates the same values as <see cref="GetRawPixelValues"/>. /// </remarks> /// <returns>An enumeration of modality LUT transformed pixel values.</returns> public IEnumerable <double> GetPixelValues() { if (PixelData == null) { yield break; } LutFunction lut = v => v; if (ModalityLut != null) { lut = v => ModalityLut[v]; } Rectangle bounds = GetBoundingBoxRounded(true); for (int x = bounds.Left; x <= bounds.Right; x++) { for (int y = bounds.Top; y <= bounds.Bottom; y++) { PointF p = new PointF(x, y); if (Contains(p)) { yield return(lut(PixelData.GetPixel(x, y))); } } } }