def displayImage(self, imp, show = True): imp.setDisplayMode(IJ.COMPOSITE) enhancer = ContrastEnhancer() enhancer.setUseStackHistogram(True) splitter = ChannelSplitter() for c in range(1, imp.getNChannels() + 1): imp.c = c enhancer.stretchHistogram(imp, 0.35) if show: imp.show()
pixel_size = 1.0 files = glob.glob(input_dir + "*.tif") files.sort() frame_i = 1 for file in files: print("Processing frame \033[1m" + str(frame_i) + "\033[0m") frame = IJ.openImage(file) # ImagePlus # Get just the signal channel frame_stack = channel_splitter.getChannel(frame, channel) # ImageStack frame = ImagePlus("Channel " + str(channel), frame_stack) # Map signal to entire 16-bit range contrast_enhancer.stretchHistogram(frame, 0.01) processor = frame.getProcessor() if(processor.getBitDepth() == 32): processor.setMinAndMax(0, 1.0) else: processor.setMinAndMax(0, processor.maxValue()) frame = ImagePlus("Frame " + str(frame_i), processor) # Convert to 8-bit, grayscale converter = ImageConverter(frame) converter.convertToGray8() # Perform median filtering processor = frame.getProcessor()