(img)
| 127 | return parser |
| 128 | |
| 129 | def segment_tissue(img): |
| 130 | img_hsv = cv2.cvtColor(img, cv2.COLOR_RGB2HSV) |
| 131 | mthresh = 7 |
| 132 | img_med = cv2.medianBlur(img_hsv[:, :, 1], mthresh) |
| 133 | _, img_prepped = cv2.threshold(img_med, 0, 255, cv2.THRESH_OTSU + cv2.THRESH_BINARY) |
| 134 | |
| 135 | close = 4 |
| 136 | kernel = np.ones((close, close), np.uint8) |
| 137 | img_prepped = cv2.morphologyEx(img_prepped, cv2.MORPH_CLOSE, kernel) |
| 138 | |
| 139 | # Find and filter contours |
| 140 | contours, hierarchy = cv2.findContours( |
| 141 | img_prepped, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE |
| 142 | ) |
| 143 | return contours, hierarchy |
| 144 | |
| 145 | def segment_tissue_deconv_stain(img): |
| 146 | """ |
no outgoing calls
no test coverage detected