Exemplo n.º 1
0
 def update_labeled_image_data(self):
     im = self.image_data.arrays.get('im')[:, :, 0]
     bw = get_cleared_binary_image(im)
     bx, by = get_region_bounds(bw)
     apd = ArrayPlotData(im=bw)
     for i in range(len(bx)):
         minc, maxc = bx[i]
         minr, maxr = by[i]
         key = "bb" + str(i)
         apd.update({key + 'topx': (minc, maxc),
                     key + 'topy': (maxr, maxr),
                     key + 'botx': (minc, maxc),
                     key + 'boty': (minr, minr),
                     key + 'leftx': (minc, minc),
                     key + 'lefty': (minr, maxr),
                     key + 'rightx': (maxc, maxc),
                     key + 'righty': (minr, maxr)})
     plot = Plot(apd)
     plot.img_plot('im', colormap=gray, origin='bottom left')
     for i in range((len(apd.arrays) - 1) / 8):
         key = 'bb' + str(i)
         plot.plot((key + 'topx', key + 'topy'), color='green',
                   line_width=3)
         plot.plot((key + 'botx', key + 'boty'), color='green',
                   line_width=3)
         plot.plot((key + 'leftx', key + 'lefty'), color='green',
                   line_width=3)
         plot.plot((key + 'rightx', key + 'righty'), color='green',
                   line_width=3)
     self.labeled_image_plot = plot
Exemplo n.º 2
0
 def test_get_region_bounds(self):
     test_img = np.zeros((1000,1000), dtype=np.uint8)
     rr, cc = circle(100,100,50)
     test_img[rr,cc] = 1
     bx, by = gzapi.get_region_bounds(test_img)
     bx, by = bx[0], by[0]
     minc, maxc = bx
     minr, maxr = by
     self.assertEqual(maxc - minc + 1, 100)
     self.assertEqual(maxr - minr + 1, 100)
     center = gzapi.get_bbox_center((minr, minc, maxr, maxc))
     self.assertTupleEqual(center, (100,100))
Exemplo n.º 3
0
 def _labeled_image_data_default(self):
     im = self.image_data.arrays.get('im')[:, :, 0]
     bw = get_cleared_binary_image(im)
     bx, by = get_region_bounds(bw)
     apd = ArrayPlotData(im=bw)
     for i in range(len(bx)):
         minc, maxc = bx[i]
         minr, maxr = by[i]
         key = "bb" + str(i)
         apd.update({key + 'topx': (minc, maxc),
                     key + 'topy': (maxr, maxr),
                     key + 'botx': (minc, maxc),
                     key + 'boty': (minr, minr),
                     key + 'leftx': (minc, minc),
                     key + 'lefty': (minr, maxr),
                     key + 'rightx': (maxc, maxc),
                     key + 'righty': (minr, maxr)})
     return apd