분류 전체보기(24)
-
Json file open
fname = 파일이름.json with open(fname, 'r') as j: myjson = json.loads(j.read()) 오류나면 with open("fname.json", encoding='utf-8', errors='ignore') as j: myjson = json.load(j, strict=False)
2021.09.09 -
Dicom 파일 익명화
import os import pydicom import glob from tqdm import tqdm import time def anotymization(target_fname, save_fname): try: Metadata = pydicom.filereader.dcmread(str(target_fname)) except: return 'file reading error' try: Metadata.PatientName = 'Anonymized' Metadata.PatientBirthDate = 'Anonymized' Metadata.PatientSex = 'Anonymized' Metadata.OtherPatientIDs = 'Anonymized' Metadata.PatientAge = 'Anon..
2021.09.09 -
유사 이미지 찾기
import pydicom import cv2 import os import glob # import matplotlib.pyplot as plt # import gdcm # import numpy as np import shutil # 영상 읽기 및 표시 img = cv2.imread('./after/20101410432567351118856660640_7988.jpg') # cv2.imshow('query', img) # 비교할 영상들이 있는 경로 ---① search_dir = './before' # 이동 경로 move_dir = './s_image/' # 이미지를 16x16 크기의 평균 해쉬로 변환 ---② def img2hash(img): gray = cv2.cvtColor(img, cv2.CO..
2021.06.16 -
Converting DCM to jpg
import cv2 import os import pydicom import numpy as np def convert_images(input_filename): dcm = pydicom.read_file(os.path.join(dcm_dir, name)) if 'MONOCHROME1' in dcm.PhotometricInterpretation: image = np.invert(dcm.pixel_array) else: image= np.asarray(dcm.pixel_array) norm_image = (image - image.min()) / (image.max() - image.min()) * 255 converted_image = cv2.cvtColor(norm_image.astype(np.uint..
2021.04.14 -
ubuntu graphic driver install error
ERROR: The Nouveau kernel driver is currently in use by your system. This driver is incompatible with the NVIDIA driver, and must be disabled before proceeding. Please consult the NVIDIA driver README and your Linux distribution's documentation for details on how to correctly disable the Nouveau kernel driver. Nouveau kernerl 충돌 에러 $ sudo update-initramfs -u $ sudo reboot $ Ctrl + Alt + F1 TTy1 ..
2020.06.15 -
Useful command
Ananconda Environment create & activate $ conda env create --name [name] python = python3.6 $ conda activate [name] $ conda env list Environment export .yml & create environment for .yml $ conda env export --name env_name > environment.yml $ conda env create --name [name] -f environment.yml Ubuntu $ scp -r copy_path servername@10.1.1.0:paste_path $ history | grep [ ]
2020.03.25