I'm currently using fo-dicon to build a simple dicom viewer in C#. I am currently increasing or decreasing the brightness and contrast by adjusting window width & center values.
How do I invert the grayscale using the InvertLut class?
public WriteableBitmap DisplayedImage {get;set;}
//...
private void ExecuteLoadImageCommand()
{
_dicomFile = DicomFile.Open(GetImageFileName());
_dicomImage = new DicomImage(_dicomFile.Dataset);
WindowLevel = _dicomImage.WindowCenter;
WindowWidth = _dicomImage.WindowWidth;
var grayScaleOptions = GrayscaleRenderOptions.FromBitRange(_dicomFile.Dataset);
Depth = grayScaleOptions.BitDepth.BitsAllocated;
DisplayedImage = _dicomImage.RenderImage().As<WriteableBitmap>();
}
With the solution provided in below fo-dicom issue, i was able to invert the image. I did not use InvertLUT class.
https://github.com/fo-dicom/fo-dicom/issues/784
I had to convert from WritableBitmap to Bitmap, then again to WritableBitmap.
Solution:
To invert: