class Stack(ImageStack): def __init__(self, title, imp): ImageStack.__init__(self, imp.width, imp.height) self.title = title self.addSlice(imp.title, imp.getProcessor()) def __add__(self, imp): if imp.width == self.width and imp.height == self.height: self.addSlice(imp.title, imp.getProcessor()) else: print "image", imp.getTitle(), "has different dimensions. Ignoring." return self def show(self): ImagePlus(self.title, self).show() w = WindowManager stack = None for id in w.getIDList(): img = w.getImage(id) if None == stack: stack = Stack("all", img) else: stack += img stack.show()