Spaces:
Sleeping
Sleeping
ddovidovich
commited on
Commit
·
c89721d
1
Parent(s):
b7a73bc
Update app.py
Browse files
app.py
CHANGED
@@ -103,6 +103,16 @@ def CCA_Analysis(orig_image,predict_image,erode_iteration,open_iteration):
|
|
103 |
teeth_count=count2
|
104 |
return image2,teeth_count
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
st.subheader("Upload Dental Panoramic X-ray Image")
|
108 |
image_file = st.file_uploader("Upload Images", type=["png","jpg","jpeg"])
|
@@ -158,10 +168,16 @@ if image_file is not None:
|
|
158 |
mask = np.uint8(predict1 * 255)
|
159 |
_, mask = cv2.threshold(mask, thresh=255/2, maxval=255, type=cv2.THRESH_BINARY)
|
160 |
cnts, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
161 |
-
img = cv2.drawContours(img, cnts, -1, (
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
|
163 |
if img is not None :
|
164 |
-
st.subheader("Predicted teeth shape")
|
165 |
st.write(img.shape)
|
166 |
st.image(img,width=1100)
|
167 |
|
|
|
103 |
teeth_count=count2
|
104 |
return image2,teeth_count
|
105 |
|
106 |
+
def detect_decays_static_th(images, dental_masks=None, threshhold=0.9):
|
107 |
+
decay_masks = []
|
108 |
+
for image, dental_mask in zip(images, dental_masks):
|
109 |
+
decay_mask = np.zeros_like(dental_mask)
|
110 |
+
image_masked_with_dental_mask = image * dental_mask
|
111 |
+
decay_mask[image_masked_with_dental_mask > threshhold*255] = 1
|
112 |
+
decay_masks.append(decay_mask)
|
113 |
+
decay_masks = np.array(decay_masks)
|
114 |
+
return decay_masks
|
115 |
+
|
116 |
|
117 |
st.subheader("Upload Dental Panoramic X-ray Image")
|
118 |
image_file = st.file_uploader("Upload Images", type=["png","jpg","jpeg"])
|
|
|
168 |
mask = np.uint8(predict1 * 255)
|
169 |
_, mask = cv2.threshold(mask, thresh=255/2, maxval=255, type=cv2.THRESH_BINARY)
|
170 |
cnts, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
171 |
+
img = cv2.drawContours(img, cnts, -1, (0, 0, 255), 2)
|
172 |
+
|
173 |
+
decay_masks = detect_decays_static_th(img, mask)
|
174 |
+
mask = np.uint8(decay_mask * 255)
|
175 |
+
_, mask = cv2.threshold(mask, thresh=255/2, maxval=255, type=cv2.THRESH_BINARY)
|
176 |
+
cnts, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
177 |
+
img = cv2.fillPoly(img, cnts, (255, 0, 0))
|
178 |
|
179 |
if img is not None :
|
180 |
+
st.subheader("Predicted teeth shape + caries zones")
|
181 |
st.write(img.shape)
|
182 |
st.image(img,width=1100)
|
183 |
|