Skip to content

Commit 37e4be0

Browse files
authored
Merge pull request #78 from qwzybug/otsu-threshold
No-argument thresold() using Otsu's method
2 parents 427f73b + e29ec40 commit 37e4be0

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/gab/opencv/OpenCV.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,17 @@ public void threshold(int threshold){
846846
Imgproc.threshold(getCurrentMat(), getCurrentMat(), threshold, 255, Imgproc.THRESH_BINARY);
847847
}
848848

849+
/**
850+
* Apply a global threshold to the image. The threshold is determined by Otsu's method, which
851+
* attempts to divide the image at a threshold which minimizes the variance of pixels in the black
852+
* and white regions.
853+
*
854+
* See: https://en.wikipedia.org/wiki/Otsu's_method
855+
*/
856+
public void threshold() {
857+
Imgproc.threshold(getCurrentMat(), getCurrentMat(), 0, 255, Imgproc.THRESH_BINARY | Imgproc.THRESH_OTSU);
858+
}
859+
849860
/**
850861
* Apply an adaptive threshold to an image. Produces a binary image
851862
* with white pixels where the original image was above the threshold

0 commit comments

Comments
 (0)