def __init__(self, carvingGraphFilename, *args, **kwargs): super(OpCarving, self).__init__(*args, **kwargs) print "[Carving id=%d] CONSTRUCTOR" % id(self) self._mst = MSTSegmentor.loadH5(carvingGraphFilename, "graph") #supervoxels of finished and saved objects self._done_lut = None self._done_seg_lut = None self._setCurrObjectName("") self.HasSegmentation.setValue(False)
def propagateDirty(self, slot, subindex, roi): key = roi.toSlice() if slot == self.Trigger or slot == self.BackgroundPriority or slot == self.NoBiasBelow: if self._mst is None: return if not self.BackgroundPriority.ready(): return if not self.NoBiasBelow.ready(): return bgPrio = self.BackgroundPriority.value noBiasBelow = self.NoBiasBelow.value print "compute new carving results with bg priority = %f, no bias below %d" % (bgPrio, noBiasBelow) labelCount = 2 params = dict() params["prios"] = [1.0, bgPrio, 1.0] params["uncertainty"] = "none" params["noBiasBelow"] = noBiasBelow unaries = numpy.zeros((self._mst.numNodes,labelCount+1)).astype(numpy.float32) #assert numpy.sum(self._mst.seeds > 2) == 0, "seeds > 2 at %r" % numpy.where(self._mst.seeds > 2) self._mst.run(unaries, **params) self.Segmentation.setDirty(slice(None)) self.HasSegmentation.setValue(True) elif slot == self.CarvingGraphFile: if self._mst is not None: #if the carving graph file is not valid, all outputs must be invalid for output in self.outputs.values(): output.setDirty(slice(0,None)) fname = self.CarvingGraphFile.value self._mst = MSTSegmentor.loadH5(fname, "graph") print "[Carving id=%d] loading graph file %s (mst=%d)" % (id(self), fname, id(self._mst)) self.Segmentation.setDirty(slice(None)) else: super(OpCarving, self).notifyDirty(slot, key)