Java Code Examples for ij.process.ByteProcessor#fill()
The following examples show how to use
ij.process.ByteProcessor#fill() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DistanceTransform5x5FloatTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Borgefors34() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); float[] weights = ChamferWeights.BORGEFORS.getFloatWeights(); DistanceTransform5x5Float algo = new DistanceTransform5x5Float(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(16, result.getf(0, 0), .01); assertEquals(14, result.getf(6, 0), .01); assertEquals(14, result.getf(0, 6), .01); assertEquals(8, result.getf(6, 6), .01); assertEquals(13, result.getf(0, 5), .01); }
Example 2
Source File: DistanceTransform3x3ShortTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_CityBlock() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); short[] weights = ChamferWeights.CITY_BLOCK.getShortWeights(); DistanceTransform3x3Short algo = new DistanceTransform3x3Short(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(8, result.get(0, 0)); assertEquals(6, result.get(6, 0)); assertEquals(6, result.get(0, 6)); assertEquals(4, result.get(6, 6)); }
Example 3
Source File: DistanceTransform5x5ShortTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
/** * Another test for chess-knight weights, to fix a bug that incorrectly * checked image bounds. */ @Test public final void testDistanceMap_UntilCorners_ChessKnight2() { ByteProcessor image = new ByteProcessor(9, 9); image.setValue(255); image.fill(); image.set(6, 6, 0); short[] weights = ChamferWeights.CHESSKNIGHT.getShortWeights(); DistanceTransform5x5Short algo = new DistanceTransform5x5Short(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(42, result.get(0, 0)); assertEquals(32, result.get(8, 0)); assertEquals(32, result.get(0, 8)); assertEquals(14, result.get(8, 8)); assertEquals(30, result.get(0, 6)); }
Example 4
Source File: DistanceTransform5x5ShortTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_ChessKnight() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); short[] weights = ChamferWeights.CHESSKNIGHT.getShortWeights(); DistanceTransform5x5Short algo = new DistanceTransform5x5Short(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(28, result.get(0, 0)); assertEquals(22, result.get(6, 0)); assertEquals(22, result.get(0, 6)); assertEquals(14, result.get(6, 6)); assertEquals(20, result.get(0, 4)); }
Example 5
Source File: DistanceTransform5x5ShortTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Borgefors34() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); short[] weights = ChamferWeights.BORGEFORS.getShortWeights(); DistanceTransform5x5Short algo = new DistanceTransform5x5Short(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(16, result.get(0, 0)); assertEquals(14, result.get(6, 0)); assertEquals(14, result.get(0, 6)); assertEquals(8, result.get(6, 6)); assertEquals(13, result.get(0, 5)); }
Example 6
Source File: DistanceTransform5x5ShortTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Weights23() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); short[] weights = ChamferWeights.WEIGHTS_23.getShortWeights(); DistanceTransform5x5Short algo = new DistanceTransform5x5Short(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(12, result.get(0, 0)); assertEquals(10, result.get(6, 0)); assertEquals(10, result.get(0, 6)); assertEquals(6, result.get(6, 6)); assertEquals(9, result.get(0, 5)); }
Example 7
Source File: DistanceTransform5x5ShortTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Chessboard() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); short[] weights = ChamferWeights.CHESSBOARD.getShortWeights(); DistanceTransform5x5Short algo = new DistanceTransform5x5Short(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(4, result.get(0, 0)); assertEquals(4, result.get(6, 0)); assertEquals(4, result.get(0, 6)); assertEquals(2, result.get(6, 6)); assertEquals(4, result.get(0, 5)); }
Example 8
Source File: DistanceTransform5x5ShortTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_CityBlock() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); short[] weights = ChamferWeights.CITY_BLOCK.getShortWeights(); DistanceTransform5x5Short algo = new DistanceTransform5x5Short(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(8, result.get(0, 0)); assertEquals(6, result.get(6, 0)); assertEquals(6, result.get(0, 6)); assertEquals(4, result.get(6, 6)); assertEquals(5, result.get(0, 5)); }
Example 9
Source File: DistanceTransform5x5ShortTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_ChessBoard() { ByteProcessor image = new ByteProcessor(12, 10); image.setBackgroundValue(0); image.setValue(0); image.fill(); for (int y = 2; y < 8; y++) { for (int x = 2; x < 10; x++) { image.set(x, y, 255); } } short[] weights = ChamferWeights.CHESSBOARD.getShortWeights(); DistanceTransform5x5Short algo = new DistanceTransform5x5Short(weights, true); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(3, result.get(4, 4)); }
Example 10
Source File: DistanceTransform3x3ShortTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Borgefors34() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); short[] weights = ChamferWeights.BORGEFORS.getShortWeights(); DistanceTransform3x3Short algo = new DistanceTransform3x3Short(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(16, result.get(0, 0)); assertEquals(14, result.get(6, 0)); assertEquals(14, result.get(0, 6)); assertEquals(8, result.get(6, 6)); }
Example 11
Source File: SpotsBuilder.java From audiveris with GNU Affero General Public License v3.0 | 6 votes |
private void eraseHeaderAreas (ByteProcessor buffer) { final int dmzDyMargin = sheet.getScale().toPixels(constants.staffVerticalMargin); buffer.setValue(255); for (SystemInfo system : sheet.getSystems()) { Staff firstStaff = system.getFirstStaff(); Staff lastStaff = system.getLastStaff(); int start = system.getBounds().x; int stop = firstStaff.getHeaderStop(); int top = firstStaff.getFirstLine().yAt(stop) - dmzDyMargin; int bot = lastStaff.getLastLine().yAt(stop) + dmzDyMargin; buffer.setRoi(start, top, stop - start + 1, bot - top + 1); buffer.fill(); buffer.resetRoi(); } buffer.setValue(0); }
Example 12
Source File: DistanceTransform5x5FloatTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Weights23() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); float[] weights = ChamferWeights.WEIGHTS_23.getFloatWeights(); DistanceTransform5x5Float algo = new DistanceTransform5x5Float(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(12, result.getf(0, 0), .01); assertEquals(10, result.getf(6, 0), .01); assertEquals(10, result.getf(0, 6), .01); assertEquals(6, result.getf(6, 6), .01); assertEquals(9, result.getf(0, 5), .01); }
Example 13
Source File: DistanceTransform5x5FloatTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Chessboard() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); float[] weights = ChamferWeights.CHESSBOARD.getFloatWeights(); DistanceTransform5x5Float algo = new DistanceTransform5x5Float(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(4, result.getf(0, 0), .01); assertEquals(4, result.getf(6, 0), .01); assertEquals(4, result.getf(0, 6), .01); assertEquals(2, result.getf(6, 6), .01); assertEquals(4, result.getf(0, 5), .01); }
Example 14
Source File: DistanceTransform3x3ShortTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Chessboard() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); short[] weights = ChamferWeights.CHESSBOARD.getShortWeights(); DistanceTransform3x3Short algo = new DistanceTransform3x3Short(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(4, result.get(0, 0)); assertEquals(4, result.get(6, 0)); assertEquals(4, result.get(0, 6)); assertEquals(2, result.get(6, 6)); }
Example 15
Source File: DistanceTransform3x3ShortTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Weights23() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); short[] weights = ChamferWeights.WEIGHTS_23.getShortWeights(); DistanceTransform3x3Short algo = new DistanceTransform3x3Short(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(12, result.get(0, 0)); assertEquals(10, result.get(6, 0)); assertEquals(10, result.get(0, 6)); assertEquals(6, result.get(6, 6)); }
Example 16
Source File: DistanceTransform3x3FloatTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Borgefors34() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); float[] weights = ChamferWeights.BORGEFORS.getFloatWeights(); DistanceTransform3x3Float algo = new DistanceTransform3x3Float(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(16, result.getf(0, 0), .01); assertEquals(14, result.getf(6, 0), .01); assertEquals(14, result.getf(0, 6), .01); assertEquals(8, result.getf(6, 6), .01); }
Example 17
Source File: DistanceTransform3x3FloatTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Weights23() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); float[] weights = ChamferWeights.WEIGHTS_23.getFloatWeights(); DistanceTransform3x3Float algo = new DistanceTransform3x3Float(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(12, result.getf(0, 0), .01); assertEquals(10, result.getf(6, 0), .01); assertEquals(10, result.getf(0, 6), .01); assertEquals(6, result.getf(6, 6), .01); }
Example 18
Source File: DistanceTransform3x3FloatTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMap_UntilCorners_Chessboard() { ByteProcessor image = new ByteProcessor(7, 7); image.setValue(255); image.fill(); image.set(4, 4, 0); float[] weights = ChamferWeights.CHESSBOARD.getFloatWeights(); DistanceTransform3x3Float algo = new DistanceTransform3x3Float(weights, false); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(4, result.getf(0, 0), .01); assertEquals(4, result.getf(6, 0), .01); assertEquals(4, result.getf(0, 6), .01); assertEquals(2, result.getf(6, 6), .01); }
Example 19
Source File: DistanceTransform3x3FloatTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Test public final void testDistanceMapImageProcessor() { ByteProcessor image = new ByteProcessor(12, 10); image.setBackgroundValue(0); image.fill(); for (int y = 2; y < 8; y++) { for (int x = 2; x < 10; x++) { image.set(x, y, 255); } } float[] weights = ChamferWeights.CHESSBOARD.getFloatWeights(); DistanceTransform3x3Float algo = new DistanceTransform3x3Float(weights, true); ImageProcessor result = algo.distanceMap(image); assertNotNull(result); assertEquals(image.getWidth(), result.getWidth()); assertEquals(image.getHeight(), result.getHeight()); assertEquals(3, result.getf(4, 4), 1e-12); }
Example 20
Source File: BinaryImagesTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates a new binary image of a square. * @return */ private final ImageProcessor createBinarySquareImage() { ByteProcessor image = new ByteProcessor(10, 10); image.setBackgroundValue(0); image.fill(); for (int y = 2; y < 8; y++) { for (int x = 2; x < 8; x++) { image.set(x, y, 255); } } return image; }