import pandas as pd
import SimpleITK as sitk
import os
import pydicom
import numpy as np
import matplotlib.pyplot as plt
import nrrd
import matplotlib.image as mpimg
from PIL import Image
import glob
import cv2
import pickle
jpg_seg_read_path = "/Users/yxk/Desktop/核磁项目/ALL_sample/seg_pic/安芮716608_000007_seg.jpg"
seg_image = Image.open(jpg_seg_read_path)
seg_img_arr = np.array(seg_image)
print(seg_img_arr.shape)
print(np.sum(seg_img_arr[:,:,0] != seg_img_arr[:,:,2]))
print(np.sum(seg_img_arr[:,:,0] != seg_img_arr[:,:,1]))
print(np.sum(seg_img_arr[:,:,1] != seg_img_arr[:,:,2]))
plt.imshow(seg_img_arr,cmap='gray')
# seg_img_arr
给三维的图片添加分割线
seg_img_arr[100:300,200,:]=[255,0,0] # 垂直线:x=200
seg_img_arr[100:300,300,:]=[0,255,0] # 垂直线:x=300
seg_img_arr[100,200:300,:]=[0,0,255] # 垂直线:x=300
seg_img_arr[300,200:300,:]=[0,0,255] # 垂直线:x=300
plt.imshow(seg_img_arr,cmap='gray')
# img_arr[mask_pos[:,:,0],:] = [255,0,0] ## 注意numpy array是可以一次性赋值的,不需要一个个赋值
# pil_img = Image.fromarray(img_arr)
# #dcm_id,_ = file.split(".")
# pil_img.save(save_mask_dir+ patient + str(id) + "_" +'{0:06d}'.format(i)+ "_mask.jpg")