MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / fill

Method fill

ij/src/main/java/ij/plugin/filter/Binary.java:191–212  ·  view source on GitHub ↗
(ImageProcessor ip, int foreground, int background)

Source from the content-addressed store, hash-verified

189 // Binary fill by Gabriel Landini, G.Landini at bham.ac.uk
190 // 21/May/2008
191 void fill(ImageProcessor ip, int foreground, int background) {
192 int width = ip.getWidth();
193 int height = ip.getHeight();
194 FloodFiller ff = new FloodFiller(ip);
195 ip.setColor(127);
196 for (int y=0; y<height; y++) {
197 if (ip.getPixel(0,y)==background) ff.fill(0, y);
198 if (ip.getPixel(width-1,y)==background) ff.fill(width-1, y);
199 }
200 for (int x=0; x<width; x++){
201 if (ip.getPixel(x,0)==background) ff.fill(x, 0);
202 if (ip.getPixel(x,height-1)==background) ff.fill(x, height-1);
203 }
204 byte[] pixels = (byte[])ip.getPixels();
205 int n = width*height;
206 for (int i=0; i<n; i++) {
207 if (pixels[i]==127)
208 pixels[i] = (byte)background;
209 else
210 pixels[i] = (byte)foreground;
211 }
212 }
213
214}

Callers 1

runMethod · 0.95

Calls 6

fillMethod · 0.95
setColorMethod · 0.65
getWidthMethod · 0.45
getHeightMethod · 0.45
getPixelMethod · 0.45
getPixelsMethod · 0.45

Tested by

no test coverage detected