-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbloodvesselsegmentationfinal.py
54 lines (39 loc) · 1.44 KB
/
bloodvesselsegmentationfinal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: utf-8 -*-
"""bloodvesselsegmentationfinal.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1ZrQR3EcvBOfmYmDmTekA8njpaoRvmVul
"""
# Commented out IPython magic to ensure Python compatibility.
import cv2
import numpy as np
# %matplotlib inline
from google.colab import files
dff = files.upload()
adv = cv2.imread('severe.tif',1) #read the image as colour
from google.colab.patches import cv2_imshow
sev = cv2.resize(adv,(250,200))
cv2_imshow(sev)
#use add weighted function - (img, alpha (contrast), img, beta (brightness), gamma
out = cv2.addWeighted( sev, 2, sev, 0,0)
cv2_imshow(out)
gray = cv2.cvtColor(out, cv2.COLOR_BGR2GRAY)
cv2_imshow(gray)
#cv2.adaptiveThreshold(src, maxValue, adaptiveMethod, thresholdType, blockSize, C[, dst])
thresh = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,31,3)
cv2_imshow(thresh)
from google.colab import files
df = files.upload()
m = cv2.imread('0-35.tif',1)
m = cv2.resize(m,(250,200))
cv2_imshow(m)
outmild = cv2.addWeighted( m, 2.5,m, 0,0)
cv2_imshow(outmild)
#BGR to gray-scale
graym = cv2.cvtColor(outmild,cv2.COLOR_BGR2GRAY)
cv2_imshow(graym)
#apply adaptive thresholding
thresh2 = cv2.adaptiveThreshold(graym, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,31,3)
cv2_imshow(thresh2)
img3 = cv2.hconcat([thresh2,thresh]) #horizontal concatenation
cv2_imshow(img3) #display both images