I looked at the code and it looked extremely buggy. https://github.com/rcd/fo-dicom/blob/master/DICOM/Imaging/DicomImage.cs
In the current buggy implementation setting the WindowCenter
or WindowWidth
properties has no effect unless Dataset.Get(DicomTag.PhotometricInterpretation) is either Monochrome1
or Monochrome2
during Load()
. This is already ridiculous, but it still cannot be used because the _renderOptions
variable is only set in a single place and is immediately used for the _pipeline
creation (not giving you chance to change it using the WindowCenter
property). Your only chance is the grayscale _renderOptions
initialization: _renderOptions = GrayscaleRenderOptions.FromDataset(Dataset);
.
The current solution: Your dataset should have
DicomTag.WindowCenter
set appropriately
DicomTag.WindowWidth != 0.0
DicomTag.PhotometricInterpretation == Monochrome1
or Monochrome2
The following code accomplishes that:
DicomDataset dataset = DicomFile.Open(fileName).Dataset;
//dataset.Set(DicomTag.WindowWidth, 200.0); //the WindowWidth must be non-zero
dataset.Add(DicomTag.WindowCenter, "100.0");
//dataset.Add(DicomTag.PhotometricInterpretation, "MONOCHROME1"); //ValueRepresentations tag is broken
dataset.Add(new DicomCodeString(DicomTag.PhotometricInterpretation, "MONOCHROME1"));
DicomImage image = new DicomImage(dataset);
image.RenderImage();
The best solution: Wait while this buggy library is fixed.