예제 #1
0
def extract_small(labels, AREA=200):
    rps = regionprops(labels)
    retain = filter(lambda x: x.area < AREA, rps)
    badlabels = np.zeros(labels.shape, np.uint16)
    for r in retain:
        badlabels[labels == r.label] = r.label
    return badlabels
예제 #2
0
 def make_bw(self):
     if self.cut_cells:
         bw = np.zeros(self.bw.shape, np.uint8)
         for cell in self.cut_cells:
             for c in cell.coords:
                 bw[c[0], c[1]] = 1
         self.bw = bw
         self.cell = regionprops(bw, self.img)[0]
         self.cut_cells = []
     else:
         self.cell = []
예제 #3
0
 def prepare_coords_set(self):
     self.cell = regionprops(self.bw.astype(np.uint8), self.img)[0]
     if 1 in self.cell.image.shape:
         self.coords_set = []
         return
     self.extract_cell_outlines()
     if not hasattr(self.cell, 'o_coords'):
         return
     coords, _ = CoordsConcaveWs(self.cell.o_coords, wlines=self.wlines, edgelen=self.EDGELEN, thres=self.THRES).run()
     if not coords.any():
         return
     self.coords_set = self.make_sort_coordsset_by_dist(coords)
     if not self.coords_set:
         return
     self.coords_set = self.coords_set[:self.CANDS_LIMIT]
     self.coords_set = self.filter_coords_by_step(self.cell.o_coords, self.coords_set)        
예제 #4
0
def make_candidates_img(cl_label, s0, s1, e0, e1, img):
    cut_label = cut_neck(cl_label, s0, s1, e0, e1)
    cand_label = label(cut_label, connectivity=1)
    cand_rps = regionprops(cand_label, img)
    return cand_rps