1 package ij.plugin.filter;
9 protected boolean backgroundIsZero;
15 if (stats.histogram[0]+stats.histogram[255]!=stats.pixelCount){
16 IJ.
error(
"8-bit binary image (0 and 255) required.");
19 backgroundIsZero =
Binary.blackBackground;
21 backgroundIsZero = !backgroundIsZero;
25 public void run(ImageProcessor ip) {
26 int xe = ip.getWidth();
27 int ye = ip.getHeight();
30 int [][] pixel =
new int [xe][ye];
33 if (!backgroundIsZero)
39 pixel[x][y]=ip.getPixel(x,y);
44 if(ip.getPixel(0,y)==0)
46 if(ip.getPixel(xe-1,y)==0)
47 ip.putPixel(xe-1,y,127);
51 if(ip.getPixel(x,0)==0)
53 if(ip.getPixel(x,ye-1)==0)
54 ip.putPixel(x,ye-1,127);
64 if (ip.getPixel(x,y)==0){
65 if(ip.getPixel(x,y-1)==127 || ip.getPixel(x-1,y)==127) {
72 for(y=ye-2;y>=1;y--) {
73 for(x=xe-2;x>=1;x--) {
74 if (ip.getPixel(x,y)==0){
75 if(ip.getPixel(x+1,y)==127 || ip.getPixel(x,y+1)==127) {
86 if(ip.getPixel(x,y)==0)
89 ip.putPixel(x,y,pixel[x][y]);
94 if (!backgroundIsZero)