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 configuration of the buggy implementation, the WindowCenter or WindowWidth properties have no effect if Dataset.Get (DicomTag.PhotometricInterpretation) is not Monochrome1 or Monochrome2 during Load() . This is ridiculous, but it still cannot be used, because the _renderOptions variable _renderOptions set only in one place and is immediately used to create _pipeline (preventing you from changing it using the WindowCenter property). The only chance is to initialize _renderOptions in shades of gray: _renderOptions = GrayscaleRenderOptions.FromDataset(Dataset); .
Current solution: your dataset must have
DicomTag.WindowCenter set accordinglyDicomTag.WindowWidth != 0.0DicomTag.PhotometricInterpretation == Monochrome1 or Monochrome2
The following code does the following:
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();
Best Solution: Wait for this error to be fixed.
source share