# Add both to the new stack newStack.addSlice(None, cp1) newStack.addSlice(None, cp2) # Create a new ImagePlus with the new stack newStack newImp = ImagePlus("my composite", newStack) newImp.setCalibration(imp1.getCalibration().copy()) # Tell the ImagePlus to represent the slices in its stack # in hyperstack form, and open it as a CompositeImage: nChannels = 2 # two color channels nSlices = stack1.getSize() # the number of slices of the original stack nFrames = 1 # only one time point newImp.setDimensions(nChannels, nSlices, nFrames) #comp = ImagePlus.CompositeImage(newImp, CompositeImage.COMPOSITE) comp = ImagePlus.CompositeImage(newImp) comp.show() imp1 = comp else: print "Opening single channel:" print "\t" + filepath1 imp1 = IJ.openImage(filepath1) imp1.show() myCalibration = imp1.getCalibration() myCalibration.setUnit("um") myCalibration.pixelWidth = float(voxelx) myCalibration.pixelHeight = float(voxely) myCalibration.pixelDepth = float(voxelz) imp1.setCalibration(myCalibration)