public void process(final BufferedImage image) { imageInput.reshape(image.getWidth(), image.getHeight()); imageBinary.reshape(image.getWidth(), image.getHeight()); imageOutput.reshape(image.getWidth(), image.getHeight()); ConvertBufferedImage.convertFromSingle(image, imageInput, imageType); final double threshold = GThresholdImageOps.computeOtsu(imageInput, 0, 255); SwingUtilities.invokeLater( new Runnable() { public void run() { selectThresh.setThreshold((int) threshold); setInputImage(image); selectThresh.getHistogramPanel().update(imageInput); selectThresh.repaint(); } }); doRefreshAll(); }