Skip to content
Snippets Groups Projects
Commit 0b357a4b authored by Tamino Huxohl's avatar Tamino Huxohl
Browse files

remove tmp file

parent fa4db774
No related branches found
No related tags found
No related merge requests found
import argparse
import os
import cv2 as cv
import numpy as np
import pydicom
from interfile2dicom import read_interfile
def to_gray(img, _min, _max):
_img = (img - _min) / (_max - _min)
_img = (_img * 255).astype(np.uint8)
_scale = 512 / img.shape[0]
_img = cv.resize(_img, None, fx=_scale, fy=_scale)
return _img
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("image", type=str)
args = parser.parse_args()
_, ext = os.path.splitext(args.image)
if ext == ".dcm":
img = pydicom.dcmread(args.image)
img = img.pixel_array / img[0x00331038].value
else:
img, _ = read_interfile(args.image)
i = 0
timeout = 100
while True:
_img = to_gray(img[i], img.min(), img.max())
_img = cv.putText(_img, str(i), (0, 30), cv.FONT_HERSHEY_SIMPLEX, 1, 255, 3)
i = (i + 1) % img.shape[0]
cv.imshow("Proj", _img)
key = cv.waitKey(timeout)
if key == ord("q"):
break
elif key == ord("p"):
timeout = 0 if timeout > 0 else 100
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment