0

I am using the frombuffer command to save DICOM image data as TIFF images. But somehwere throughout this process, the image intensities are inverted (inverted LUT). Any idea on how to overcome this?

I have tried using the ImageOps.invert function from PIL, but if gives me "not supported for this image mode" error.

This is the code I'm using:

import dicom
import Image
import PIL.ImageOps

meta=dicom.read_file("DicomImage.dcm") 
imHeight=meta.Rows
imWidth=meta.Columns 
imSize=(imWidth,imHeight)
TT=Image.frombuffer("L",imSize,meta.PixelData,"raw","L",0,1)
TT.save("testOUTPUT.tiff","TIFF",compression="none")

Any guidance is appreciated ... Python 2.7 PIL 1.1.7 Pydicom 0.9.6

Suever
  • 64,497
  • 14
  • 82
  • 101
Masrawy
  • 33
  • 1
  • 5

1 Answers1

2

Rather than "" for the raw mode, you should be using one of the mode strings from the documentation. Try "L" or "L;I", one or the other should be correct.

Jonathan Root
  • 535
  • 2
  • 14
  • 31
Mark Ransom
  • 299,747
  • 42
  • 398
  • 622