I am not an experienced programmer, just need to add a DICOM viewer to my VS2010 project. I can display the image in Windows Forms, however can't figure out how to change the window center and width. Here is my script:
DicomImage image = new DicomImage(_filename);
int maxV = image.NumberOfFrames;
sbSlice.Maximum = maxV - 1;
image.WindowCenter = 7.0;
double wc = image.WindowCenter;
double ww = image.WindowWidth;
Image result = image.RenderImage(0);
DisplayImage(result);
It did not work. I don't know if this is the right approach.
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
orWindowWidth
properties has no effect unless Dataset.Get(DicomTag.PhotometricInterpretation) is eitherMonochrome1
orMonochrome2
duringLoad()
. 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 theWindowCenter
property). Your only chance is the grayscale_renderOptions
initialization:_renderOptions = GrayscaleRenderOptions.FromDataset(Dataset);
.The current solution: Your dataset should have
DicomTag.WindowCenter
set appropriatelyDicomTag.WindowWidth != 0.0
DicomTag.PhotometricInterpretation == Monochrome1
orMonochrome2
The following code accomplishes that:
The best solution: Wait while this buggy library is fixed.