├── LuncCancerTrain.py ├── NeuralNetwork.py ├── PredictCancer.py ├── README.md └── dataset_create.py /LuncCancerTrain.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | from scipy import ndimage 3 | import numpy as np 4 | import os.path 5 | from math import sqrt 6 | 7 | def preprocess(img): 8 | img_filted=cv2.medianBlur(img,5)#5 is mask size 9 | thresh,img_thresh=cv2.threshold(img_filted,127,255,cv2.THRESH_BINARY) 10 | kernel=np.ones((7,7),np.uint8) 11 | img_opened=cv2.morphologyEx(img_thresh,cv2.MORPH_OPEN,kernel) 12 | img_closed=cv2.morphologyEx(img_opened,cv2.MORPH_CLOSE,kernel) 13 | return img_closed,img_filted,img_thresh,img_opened 14 | 15 | def lung_side_detect(c_index,contours,img): 16 | img_roied_left_lung=img 17 | img_roied_right_lung=img 18 | #left lung check 19 | x,y,w,h=cv2.boundingRect(contours[c_index[0]]) 20 | M=cv2.moments(contours[c_index[0]]) 21 | cx=int(M['m10']/M['m00']) 22 | cy=int(M['m01']/M['m00']) 23 | #print(cx,cy,int(img.shape[1]/2)) 24 | if(cx