You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed one issue with the 'GetMinMax' function. If by chance you have a dataset where all the pixels are the same value and they are equal to the padding value provided, then it will return double.MaxValue / double.MinValue as the range. I think this can be corrected as follows:
public DicomRange<double> GetMinMax(int padding)
{
// null or empty return a MinMax of 0/0
if (Data == null || Data.Length == 0)
return default(DicomRange<double>);
// set to the first value to start
var min = Data[0];
var max = Data[0];
var data = Data;
var length = data.Length;
// loop thru the rest of the pixels, updating the min/max if a new min/max is found
for (var i = 1; i < length; i++)
{
var value = data[i];
if (value == padding) continue;
if (value > max) max = value;
else if (value < min) min = value;
}
return new DicomRange<double>(min, max);
}
Best Regards,
Jamie
The text was updated successfully, but these errors were encountered:
Looks like the original code tried to pick the min/max without padding? If data[0] is the padding value this will include that value in the final range. That's quite likely to be the case, for example, in CT where padding values are used to define the area outside a cylindrical acquisition region and data[0] is likely to be padding. When all values are the padding value the original code returning double.Max, double.Min to represent the empty range seems valid. @jwbruce93 can you provide a real world example where this is important?
fo-dicom/DICOM/Imaging/Render/PixelData.cs
Line 704 in 9d2e833
Hi,
I noticed one issue with the 'GetMinMax' function. If by chance you have a dataset where all the pixels are the same value and they are equal to the padding value provided, then it will return double.MaxValue / double.MinValue as the range. I think this can be corrected as follows:
Best Regards,
Jamie
The text was updated successfully, but these errors were encountered: