Remove dilation in segmentation mask refinement (#29)

This produces cleaner edges for flat documents.
This commit is contained in:
Pierre-Yves Nicolas
2025-09-18 12:45:23 +02:00
parent 2647874803
commit 41ff4e4cad

View File

@@ -89,12 +89,7 @@ fun refineMask(original: Mat): Mat {
val opened = Mat() val opened = Mat()
Imgproc.morphologyEx(closed, opened, Imgproc.MORPH_OPEN, kernelOpen) Imgproc.morphologyEx(closed, opened, Imgproc.MORPH_OPEN, kernelOpen)
// Step 3: Light dilation (connects almost touching parts) return opened
val kernelDilate = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, Size(5.0, 5.0))
val dilated = Mat()
Imgproc.dilate(opened, dilated, kernelDilate, org.opencv.core.Point(-1.0, -1.0), 1)
return dilated
} }
fun extractDocument(originalBitmap: Bitmap, quad: Quad, rotationDegrees: Int): Bitmap { fun extractDocument(originalBitmap: Bitmap, quad: Quad, rotationDegrees: Int): Bitmap {