DICOM Oak - Image Window Level Change

I am not an experienced programmer, I just need to add the DICOM viewer to my VS2010 project. I can display the image in Windows Forms, but I can’t figure out how to change the center of the window and the 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); 

This did not work. I do not know if this is right.

+6
source share
2 answers

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 accordingly
  • DicomTag.WindowWidth != 0.0
  • DicomTag.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.

+1
source

The DicomImage class was not created to be used to implement an image viewer. It was created for rendering images in DICOM Dump and testing image compression / decompression codecs. Maybe it was a mistake to include it in the library?

It is difficult for me to make a mistake in the code as erroneous when it is used for something much larger than its intended functionality.

However, I spent some time modifying the code so that the WindowCenter / WindowWidth properties are applied to the rendered image. These changes can be found in the Git repository.

 var img = new DicomImage(fileName); img.WindowCenter = 2048.0; img.WindowWidth = 4096.0; DisplayImage(img.RenderImage(0)); 
+5
source

All Articles