My turn to nitpick!
RGB to grayscale: V = r x g x b/3 (one line).
The Sobel operation is at most 4 nested loops (really only 3) for a total of ~7 lines of code, depending on how you like your white space.
Fold the summation into your Sobel function without requiring another line.
The most complicated thing used from the OpenCV library (which I'm well aware is C++!) is JPEG decoding. OK, I'm avoiding swirling, but then it isn't needed to solve the CAPTCHA anyway.