Exemplo n.º 1
0
  public void process(BufferedImage input) {
    setInputImage(input);

    image.reshape(input.getWidth(), input.getHeight());
    transform.reshape(input.getWidth(), input.getHeight());
    magnitude.reshape(input.getWidth(), input.getHeight());
    phase.reshape(input.getWidth(), input.getHeight());

    ConvertBufferedImage.convertFrom(input, image, true);
    fft.forward(image, transform);

    GDiscreteFourierTransformOps.shiftZeroFrequency(transform, true);

    GDiscreteFourierTransformOps.magnitude(transform, magnitude);
    GDiscreteFourierTransformOps.phase(transform, phase);

    // Convert it to a log scale for visibility
    GPixelMath.log(magnitude, magnitude);

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            setPreferredSize(new Dimension(image.width + 50, image.height + 20));
            processedImage = true;
          }
        });

    doRefreshAll();
  }
  public void process(final BufferedImage buffLeft, final BufferedImage buffRight) {
    imageLeft.reshape(buffLeft.getWidth(), buffLeft.getHeight());
    imageRight.reshape(buffRight.getWidth(), buffRight.getHeight());
    grayLeft.reshape(buffLeft.getWidth(), buffLeft.getHeight());
    grayRight.reshape(buffRight.getWidth(), buffRight.getHeight());

    ConvertBufferedImage.convertFromMulti(buffLeft, imageLeft, true, imageType);
    ConvertBufferedImage.convertFromMulti(buffRight, imageRight, true, imageType);

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            panel.setImages(buffLeft, buffRight);
            processedImage = true;
            doRefreshAll();
          }
        });
  }
Exemplo n.º 3
0
  private void scaleUpLayers() {
    T l = pyramid.getLayer(0);
    if (upscale == null) {
      interp = (InterpolatePixelS<T>) FactoryInterpolation.nearestNeighborPixelS(l.getClass());
      upscale = (T) l._createNew(l.width, l.height);
    } else {
      upscale.reshape(l.width, l.height);
    }

    int N = pyramid.getNumLayers();

    for (int i = 0; i < N; i++) {
      new FDistort(pyramid.getLayer(i), upscale).interpNN().scaleExt().apply();
      BufferedImage b = ConvertBufferedImage.convertTo(upscale, null, true);
      if (showScales) addImage(b, String.format("%5.2f", pyramid.getScale(i)));
      else addImage(b, String.format("%5.2f", pyramid.getSigma(i)));
    }
  }
  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();
  }
  public void evaluate(String dataName, TldTracker<T, ?> tracker) {
    System.out.println("Processing " + dataName);

    String path = "data/track_rect/TLD/" + dataName;

    Rectangle2D_F64 initial = UtilTldData.parseRectangle(path + "/init.txt");
    Rectangle2D_F64 found = new Rectangle2D_F64();

    TldVisualizationPanel gui = null;

    String imageType = new File(path + "/00001.jpg").exists() ? "jpg" : "png";

    int imageNum = 0;
    while (true) {
      String imageName = String.format("%s/%05d.%s", path, imageNum + 1, imageType);
      BufferedImage image = UtilImageIO.loadImage(imageName);
      if (image == null) break;

      input.reshape(image.getWidth(), image.getHeight());
      ConvertBufferedImage.convertFrom(image, input, true);

      boolean detected;

      if (imageNum == 0) {
        gui = new TldVisualizationPanel(this);
        gui.setFrame(image);
        gui.setSelectRectangle(false);
        ShowImages.showWindow(gui, dataName);
        tracker.initialize(
            input, (int) initial.p0.x, (int) initial.p0.y, (int) initial.p1.x, (int) initial.p1.y);
        detected = true;
      } else {
        detected = tracker.track(input);
        found.set(tracker.getTargetRegion());
      }

      if (!detected) {
        System.out.println("No Detection");
      } else {
        System.out.printf(
            "Detection: %f,%f,%f,%f\n", found.p0.x, found.p0.y, found.p1.x, found.p1.y);

        Graphics2D g2 = image.createGraphics();

        int w = (int) found.getWidth();
        int h = (int) found.getHeight();

        g2.drawRect((int) found.p0.x, (int) found.p0.y, w, h);
      }

      gui.setFrame(image);
      gui.update(tracker, detected);
      gui.repaint();

      imageNum++;

      while (paused) {
        Thread.yield();
      }

      //			BoofMiscOps.pause(30);
    }
    System.out.println();
  }