Académique Documents
Professionnel Documents
Culture Documents
process;
import java.awt.*;
/** This class processes binary images. */
public class BinaryProcessor extends ByteProcessor {
// 2012/03/08: 17,5,0->2
// 2012/03/09: 17,5,2->0
static int[] table =
//0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
1
{0,0,0,1,0,0,1,3,0,0,3,1,1,0,1,3,0,0,0,0,0,0,0,0,2,0,2,0,3,0,3,
3,
0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,0,2,
2,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,
2,0,0,0,0,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,0,0,0,0,3,0,0,0,3,0,2,
0,
0,0,3,1,0,0,1,3,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,
3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,
2,3,1,3,0,0,1,3,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,
2,3,0,1,0,0,0,1,0,0,0,0,0,0,0,0,3,3,0,1,0,0,0,0,2,2,0,0,2,0,0,
0};
private ByteProcessor parent;
/** Creates a BinaryProcessor from a ByteProcessor. The ByteProcessor
must contain a binary image (pixels values are either 0 or 255).
Backgound is assumed to be white. */
public BinaryProcessor(ByteProcessor ip) {
super(ip.getWidth(), ip.getHeight(), (byte[])ip.getPixels(), ip.
getColorModel());
setRoi(ip.getRoi());
parent = ip;
}
static final int OUTLINE=0;
void process(int type, int count) {
int p1, p2, p3, p4, p5, p6, p7, p8, p9;
int inc = roiHeight/25;
if (inc<1) inc = 1;
int bgColor = 255;
if (parent.isInvertedLut())
bgColor = 0;
byte[] pixels2 = (byte[])parent.getPixelsCopy();
int offset, v=0, sum;
int rowOffset = width;
for (int y=yMin; y<=yMax; y++) {
offset = xMin + y * width;
p2 = pixels2[offset-rowOffset-1]&0xff;
p3 = pixels2[offset-rowOffset]&0xff;
p5 = pixels2[offset-1]&0xff;
p6 = pixels2[offset]&0xff;
p8 = pixels2[offset+rowOffset-1]&0xff;
p9 = pixels2[offset+rowOffset]&0xff;
if (y%inc==0)
showProgress((double)(y-roiY)/roiHeight);
}
hideProgress();
return pixelsRemoved;
}
public void outline() {
process(OUTLINE, 0);
}
}