|
a |
|
b/leukemia detect.py |
|
|
1 |
#!/usr/bin/env python |
|
|
2 |
# coding: utf-8 |
|
|
3 |
|
|
|
4 |
# In[40]: |
|
|
5 |
|
|
|
6 |
|
|
|
7 |
import cv2 |
|
|
8 |
import matplotlib.pyplot as plt |
|
|
9 |
|
|
|
10 |
img = cv2.imread('F1.jpg') |
|
|
11 |
img = cv2.resize(img, (200,200)) |
|
|
12 |
imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) |
|
|
13 |
imgBlur = cv2.GaussianBlur(imgGray, (7,7), 0) |
|
|
14 |
|
|
|
15 |
# Change the values of Threshold for further fine tuning |
|
|
16 |
ret, thresh = cv2.threshold(imgBlur, 140, 190, 0) |
|
|
17 |
|
|
|
18 |
# Create image copy to draw outline for cancer cells |
|
|
19 |
img_res = img.copy() |
|
|
20 |
|
|
|
21 |
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) |
|
|
22 |
|
|
|
23 |
img_cancer = cv2.drawContours(img, contours, -1, (125,125,0), 2) |
|
|
24 |
|
|
|
25 |
cv2.imshow('input', img) |
|
|
26 |
cv2.imshow('output', img_res) |
|
|
27 |
cv2.imshow('contrast',img_cancer+img) |
|
|
28 |
cv2.waitKey(0) |
|
|
29 |
cv2.destroyAllWindows() |
|
|
30 |
|
|
|
31 |
|
|
|
32 |
# In[ ]: |
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|