private synchronized void renderOutput() {
    switch (calibGUI.getSelectedView()) {
      case 0:
        workImage.createGraphics().drawImage(input, null, null);
        break;

      case 1:
        VisualizeBinaryData.renderBinary(alg.getBinary(), false, workImage);
        break;

      case 2:
        renderClusters();
        break;

      default:
        throw new RuntimeException("Unknown mode");
    }
    Graphics2D g2 = workImage.createGraphics();
    if (foundTarget) {
      if (calibGUI.isShowBound()) {
        //				Polygon2D_I32 bounds =  alg.getFindBound().getBoundPolygon();
        //				drawBounds(g2, bounds);
      }

      if (calibGUI.isShowNumbers()) {
        drawNumbers(g2, alg.getCalibrationPoints(), null, 1);
      }
      calibGUI.setSuccessMessage("FOUND", true);
    } else {
      if (calibGUI.isShowBound()) {
        //				Polygon2D_I32 bounds =  alg.getFindBound().getBoundPolygon();
        //				drawBounds(g2, bounds);
      }

      calibGUI.setSuccessMessage("FAILED", false);
    }

    if (calibGUI.isShowPoints()) {
      List<Point2D_F64> candidates = alg.getCalibrationPoints();
      for (Point2D_F64 c : candidates) {
        VisualizeFeatures.drawPoint(g2, (int) (c.x + 0.5), (int) (c.y + 0.5), 1, Color.RED);
      }
    }

    if (calibGUI.doShowGraph) {
      System.out.println("Maybe I should add this back in with the new detector some how");
    }

    gui.setBufferedImage(workImage);
    gui.setScale(calibGUI.getScale());
    gui.repaint();

    processed = true;
  }
  public DetectCalibrationChessApp() {

    gray = new ImageFloat32(1, 1);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    calibGUI = new GridCalibPanel(true);
    calibGUI.setListener(this);
    calibGUI.setMinimumSize(calibGUI.getPreferredSize());

    panel.add(gui, BorderLayout.CENTER);
    panel.add(calibGUI, BorderLayout.WEST);

    gui.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            System.out.println("clicked at " + e.getX() + " " + e.getY());
          }
        });

    setMainGUI(panel);
  }
  private synchronized void detectTarget() {
    if (calibGUI.isManual()) alg.setUserBinaryThreshold(calibGUI.getThresholdLevel());
    else alg.setUserBinaryThreshold(-1);

    foundTarget = alg.process(gray);
  }