Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #DICOM IMage
  2. dataset = dicom.read_file("1.3.6.1.4.1.5962.99.1.2786334768.1849416866.1385765836848.376.0.dcm")
  3. dsw = png.Writer(width=dataset[0x28, 0x10].value,height=dataset[0x28, 0x11].value, greyscale=True, bitdepth=dataset[0x28, 0x102].value)
  4. lista = list()
  5. aux = list()
  6. #Changing only for a test because the error
  7. for i in range(0, 512):
  8. for j in range(0, 512):
  9. if dataset.pixel_array[i][j]== -2000:
  10. aux.append(0)
  11. else:
  12. aux.append(int(dataset.pixel_array[i][j]))
  13. lista.append(aux)
  14. #lista= [[x for x in [i for i in range(0,512)]] for y in range(0, 512)]
  15. dw = png.Writer(width=512, height=512, greyscale= True, bitdepth=16)
  16. dw.write(open('imagetest.png', 'wb'), lista)
  17. #png.from_array(lista, 'L', info={'bitdepth':16}).save('imagetest.png')
  18. print("Escritor criado com sucesso!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement