def draw_center_for_check(dcm_path, id, slicelocalization,PixelSpacing,sax, point, points):
debug_folder = os.path.join('E:', 'calc', 'center_find')
if not os.path.isdir(debug_folder):
os.mkdir(debug_folder)
ds = pydicom.read_file(dcm_path)
img = convert_to_grayscale_with_increase_brightness_fast(ds.pixel_array, 1)
raw=int(round(point[0], 0))
#F_col=float(col)
col=int(round(point[1], 0))
#F_raw=float(raw)
row_spacing =PixelSpacing[0]
row_spacing = float(row_spacing)
row_spacing_size=(32.0*1.4)/row_spacing
col_spacing = PixelSpacing[1]
col_spacing = float(col_spacing)
col_spacing_size=(32.0*1.4)/col_spacing
L_raw=raw-int(row_spacing_size)
R_raw=raw+int(row_spacing_size)
L_col=col-int(col_spacing_size)
R_col=col+int(col_spacing_size)
crop_img = img[L_raw:R_raw, L_col:R_col]
img_shape = (64, 64)
crop_img = imresize(crop_img, img_shape)
crop_img=exposure.equalize_hist(crop_img)
crop_img=crop_img*255
crop_img=crop_img.astype(np.uint8)
#cv2.circle(img, (int(round(point[1], 0)), int(round(point[0], 0))), 5, 255, 3)
#cv2.circle(img, 15, 25, 5, 255, 3)
#img = cv2.line(img, (points[1], points[0]), (points[3], points[2]), 127, thickness=2)
#img = cv2.line(img, (points[5], points[4]), (points[7], points[6]), 127, thickness=2)
#img = cv2.line(img, (12, 13), (112, 223), 127, thickness=2)
#img = cv2.line(img, (12,115), (112,256), 127, thickness=2)
#show_image(img)
cv2.imwrite(os.path.join(debug_folder, str(id) + '_' + sax + '_'+ slicelocalization+'.jpg'), crop_img)
find_ventricle_location.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录