Can't get Canny Edge Treshold right
I'm trying to extract digits from an analog electricity meter.
I have for example following picture:
I know that the lightning on this picture isn't equal everywhere, but it's really hard to get this equal due to reflection and etc.
When I'm performing Grayscale, Gaussian Blur & Canny Edge on this image, I can't get a decent result. The issue is that I either have to put the Canny Edge treshold too high which causes some digits unreadable or either have to put the Canny Edge treshold too low which causes too much details to be included in the image.
Example of too high treshold:
Code: Imgproc.Canny(image, imgCanny, 60, 60/3);
Example of too low treshold:
Code: Imgproc.Canny(image, imgCanny, 35, 35/3);
Is there any way to perform some kind of 'Adaptive Treshold Canny Edge' on this? Thanks!
Have you try in NiBlackThreshold opencv_contrib?
Thanks for this suggestion @LBerger, but I can't find the XImgProc in my jar or .so and it's a real pain to build these again.. Any suggestion that doesn't require the extra modules? Thanks!
In canny you can use function with your gradient x and y
Thanks for this suggestion. Can you please give me some more resources or info on the gradient x and y usage? Or how it would help me out with this? I btw enabled the
L2gradient
flag, which already makes it a little bit better.int t = threshold(...,THRESH_OTSU)
is quite often used for this. (you would throw away the result image, and only keep the threshold number for Canny later)Thanks for your suggestion @berak ! I tried to use:
Imgproc.threshold(image, imgCanny, 0, 255, Imgproc.THRESH_BINARY | Imgproc.THRESH_OTSU);
, but it doesn't really give a nice result. (You can see the result here).@berak , tried to keep the treshold number, but I get 116 as treshold which is way too high..
Using paillou filter (in opencv_contrib) with canny I can get :
Now It's take time to get this result