application_vnd.jupyter.stderr_output_1.png
from PIL import Image

from PIL import Image

import cv2

import glob

import glob

import os

import os

import os

import os

import pydicom

import pydicom

import pydicom

import numpy as np
import pandas as pd
import os

import cv2
import os
import pydicom
inputdir = '../input/sample images/'
outdir = './'
test_list = [os.path.basename(x) for x in glob.glob(inputdir + './*.dcm')]
for f in test_list:
    ds = pydicom.read_file(inputdir + f)
    img = ds.pixel_array
    cv2.imwrite(outdir + f.replace('.dcm', '.png'), img)

import os
import pydicom
import glob
from PIL import Image
inputdir = '../input/sample images/'
outdir = './'
test_list = [os.path.basename(x) for x in glob.glob(inputdir + './*.dcm')]
for f in test_list:
    ds = pydicom.read_file(inputdir + f)
    img = ds.pixel_array
    img_mem = Image.fromarray(img)
    img_mem.save(outdir + f.replace('.dcm', '.png'))

import os
import pydicom
import glob
from PIL import Image
inputdir = '../input/sample images/'
outdir = './'
test_list = [os.path.basename(x) for x in glob.glob(inputdir + './*.dcm')]
for f in test_list:
    ds = pydicom.read_file(inputdir + f)
    img = ds.pixel_array
    img_mem = Image.fromarray(img)
    img_mem.save(outdir + f.replace('.dcm', '.jp2'))