Skip to content

Commit 684936f

Browse files
committed
Binarize->Monoscaler and it now inherits ImageProcess.
The monoscalar now has a process method and is an ImageProcess.
1 parent 4dfdf49 commit 684936f

File tree

2 files changed

+23
-53
lines changed

2 files changed

+23
-53
lines changed

Binarize.java

-53
This file was deleted.

Monoscaler.java

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Convert a grayscale image to a binary image.
3+
*
4+
* @author Christopher Sasarak
5+
*/
6+
import javax.media.jai.*;
7+
import java.awt.image.RenderedImage;
8+
9+
public class Monoscaler implements ImageProcess {
10+
/**
11+
* This method accepts a RenderedImage and converts it to
12+
* binary.
13+
*
14+
* @param img The source image.
15+
* @return RenderedImage The image after being processed by the method.
16+
*/
17+
public RenderedImage process(RenderedImage img){
18+
Histogram hist = (Histogram)JAI.create("histogram", img).getProperty("histogram");
19+
double[] threshold = hist.getPTileThreshold(0.5);
20+
21+
return JAI.create("binarize", img, new Double(threshold[0]));
22+
}
23+
}

0 commit comments

Comments
 (0)