From 218573c34017164088af7ed8da7cc3f85c5bf63c Mon Sep 17 00:00:00 2001 From: bmad4ever Date: Fri, 21 Aug 2026 15:17:12 +0100 Subject: [PATCH] fix orientation thresholding in anisotropic_image_segmentation.py Same as #29757 in 5.x The Python tutorial sample thresholds the orientation with a single cv.threshold call, passing HighThr as the maxval argument rather than as an upper bound: ```_, imgOrientationBin = cv.threshold(imgOrientation, LowThr, HighThr, cv.THRESH_BINARY)``` That computes imgOrientation > LowThr ? HighThr : 0, so HighThr never restricts the angle. The C++ counterpart uses inRange(imgOrientation, Scalar(LowThr), Scalar(HighThr), imgOrientationBin), and the tutorial text states "LowThr and HighThr define orientation range", so the C++ behaviour is the intended one. --- .../anisotropic_image_segmentation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/python/tutorial_code/imgProc/anisotropic_image_segmentation/anisotropic_image_segmentation.py b/samples/python/tutorial_code/imgProc/anisotropic_image_segmentation/anisotropic_image_segmentation.py index a8a9ccb3cc..3a72ffebd1 100644 --- a/samples/python/tutorial_code/imgProc/anisotropic_image_segmentation/anisotropic_image_segmentation.py +++ b/samples/python/tutorial_code/imgProc/anisotropic_image_segmentation/anisotropic_image_segmentation.py @@ -74,7 +74,7 @@ imgCoherency, imgOrientation = calcGST(imgIn, W) ## [thresholding] _, imgCoherencyBin = cv.threshold(imgCoherency, C_Thr, 255, cv.THRESH_BINARY) -_, imgOrientationBin = cv.threshold(imgOrientation, LowThr, HighThr, cv.THRESH_BINARY) +imgOrientationBin = cv.inRange(imgOrientation, LowThr, HighThr) ## [thresholding] ## [combining]