@Test public void testBlobDetector() { int[] data = new int[] { 0, 0, 8, 9, 8, 0, 0, 0, 0, 0, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; BlobDetector detector = new BasicBlobDetector(); BlobDetectionResult blobs = detector.getBlobs(data, 8, 8, new BlobSampleClassifier() { @Override public boolean isSeedPoint(int sample) { return sample == 9; } @Override public boolean isBlobPoint(int sample) { return sample == 8; } }); List<Rectangle2> boundingRectangles = blobs.getBoundingRectangles(); System.out.println(boundingRectangles); List<Rectangle2> expected = Lists.newArrayList(new Rectangle2(2.0, 6.0, 3.0, 1.0), new Rectangle2(1.0, 2.0, 3.0, 2.0)); Assert.assertEquals(expected.size(), boundingRectangles.size()); for (int i = 0; i < expected.size(); i++) { Assert.assertTrue(expected.get(i).equal(boundingRectangles.get(i), 0.01)); } }
@Override public BlobDetectionResult getBlobs(int[] data, int numRows, int numColumns, BlobSampleClassifier sampler) { BlobTask task = new BlobTask(data, numRows, numColumns, sampler); return task.findBlobs(); }
BasicBlobDetector implements BlobDetector { @Override public BlobDetectionResult getBlobs(int[] data, int numRows, int numColumns, BlobSampleClassifier sampler) { BlobTask task = new BlobTask(data, numRows, numColumns, sampler); return task.findBlobs(); } }
BasicBlobDetector implements BlobDetector { @Override public BlobDetectionResult getBlobs(int[] data, int numRows, int numColumns, BlobSampleClassifier sampler) { BlobTask task = new BlobTask(data, numRows, numColumns, sampler); return task.findBlobs(); }  }
BasicBlobDetector implements BlobDetector { @Override public BlobDetectionResult getBlobs(int[] data, int numRows, int numColumns, BlobSampleClassifier sampler) { BlobTask task = new BlobTask(data, numRows, numColumns, sampler); return task.findBlobs(); }  @Override BlobDetectionResult getBlobs(int[] data, int numRows, int numColumns, BlobSampleClassifier sampler); }
BasicBlobDetector implements BlobDetector { @Override public BlobDetectionResult getBlobs(int[] data, int numRows, int numColumns, BlobSampleClassifier sampler) { BlobTask task = new BlobTask(data, numRows, numColumns, sampler); return task.findBlobs(); }  @Override BlobDetectionResult getBlobs(int[] data, int numRows, int numColumns, BlobSampleClassifier sampler);  }