Skip to content

Commit 36c67d4

Browse files
committed
Catch IllegalArgumentException when the image is not binary
1 parent 6372ade commit 36c67d4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

MonoscaleProcess.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public RenderedImage process(RenderedImage img){
1818
Histogram hist = (Histogram)JAI.create("histogram", img).getProperty("histogram");
1919
double[] threshold = hist.getMaxVarianceThreshold();
2020

21-
return JAI.create("binarize", img, new Double(threshold[0]));
21+
try{
22+
return JAI.create("binarize", img, new Double(threshold[0]));
23+
}catch(IllegalArgumentException e){
24+
System.err.println("Cannot binarize image: " + e.getMessage());
25+
return img;
26+
}
2227
}
2328
}

0 commit comments

Comments
 (0)