コード例 #1
0
  private void setTargetLocation(int x, int y) {
    ImageMiscOps.fillUniform(image, rand, 0, 1);
    ImageMiscOps.fillRectangle(image, 100, cornerX, cornerY, 20, 20);
    pyramid.process(image);

    for (int i = 0; i < pyramid.getNumLayers(); i++) {
      GradientSobel.process(
          pyramid.getLayer(i),
          derivX[i],
          derivY[i],
          new ImageBorder1D_F32(BorderIndex1D_Extend.class));
    }
  }
コード例 #2
0
  @Override
  public void renderTarget(ImageFloat32 original, List<CalibrationObservation> solutions) {
    ImageMiscOps.fill(original, 255);

    int numRows = config.numRows * 2 - 1;
    int numCols = config.numCols * 2 - 1;

    int square = original.getWidth() / (Math.max(numRows, numCols) + 4);

    int targetWidth = square * numCols;
    int targetHeight = square * numRows;

    int x0 = (original.width - targetWidth) / 2;
    int y0 = (original.height - targetHeight) / 2;

    for (int i = 0; i < numRows; i += 2) {
      int y = y0 + i * square;

      for (int j = 0; j < numCols; j += 2) {
        int x = x0 + j * square;
        ImageMiscOps.fillRectangle(original, 0, x, y, square, square);
      }
    }

    int pointsRow = numRows + 1;
    int pointsCol = numCols + 1;

    CalibrationObservation set = new CalibrationObservation();
    int gridIndex = 0;
    for (int i = 0; i < pointsRow; i++) {
      for (int j = 0; j < pointsCol; j++, gridIndex++) {
        double y = y0 + i * square;
        double x = x0 + j * square;
        set.add(new Point2D_F64(x, y), gridIndex);
      }
    }
    solutions.add(set);
  }
コード例 #3
0
  @Test
  public void basic() {
    ImageUInt8 image = new ImageUInt8(400, 500);

    int value = 200;
    ImageMiscOps.fillRectangle(image, value, 20, 30, 40, 40);

    PolygonEdgeScore<ImageUInt8> alg =
        new PolygonEdgeScore<ImageUInt8>(2, 2, 10, value * 0.9, ImageUInt8.class);

    Polygon2D_F64 polygon = new Polygon2D_F64(4);

    UtilPolygons2D_F64.convert(new Rectangle2D_F64(20, 30, 60, 70), polygon);

    alg.setImage(image);
    assertTrue(alg.validate(polygon));
    assertEquals(value, alg.getAverageEdgeIntensity(), 1e-8);

    UtilPolygons2D_F64.convert(new Rectangle2D_F64(24, 30, 60, 70), polygon);

    // test a negative case
    assertFalse(alg.validate(polygon));
    assertEquals(value * 3.0 / 4.0, alg.getAverageEdgeIntensity(), 1e-8);
  }