自适应阈值.TRIANGLE
对于阈值操作,不仅可以手动设置阈值,还可以自动计算阈值,即根据输入源本身特征进行自适应阈值。本节自适应为TRIANGLE。TRIANGLE的含义为将灰度输入源的直方图寻找其最大峰值,从最大峰值作为新三角形的顶点作到水平轴的45°连线,在这个构成的三角形作到直方图的距离d,d即为阈值T。在OpenCV中,其枚举为Imgproc.THRESH_TRIANGLE。
其几何描述如下:
Java代码(JavaFX Controller层)
public class Controller{
@FXML private Text fxText;
@FXML private ImageView imageView;
@FXML private Label resultLabel;
@FXML public void handleButtonEvent(ActionEvent actionEvent) throws IOException {
Node source = (Node) actionEvent.getSource();
Window theStage = source.getScene().getWindow();
FileChooser fileChooser = new FileChooser