def calculateThreshold(image, roi, method): if roi != None: bounds = roi.getBounds() stack = image.getStack() newstack = ImageStack(bounds.width, bounds.height) for i in xrange(1, stack.getSize() + 1): ip = stack.getProcessor(i).duplicate() ip.fillOutside(roi) ip.setRoi(roi) c = ip.crop() newstack.addSlice(str(i), c) imp = ImagePlus("ThresholdImage", newstack) else: imp = image thresholder = Auto_Threshold() result = thresholder.exec(imp, method, False, False, True, False, False, True) return result
def getThreshold(self, imp, method): thresholder = Auto_Threshold() duplicator = Duplicator() tmp = duplicator.run(imp) return thresholder.exec(tmp, method, False, False, True, False, False, True)