129 points · by cidquick · 13y ago · 56 comments
Speech recognition: https://gist.github.com/4520930
Laplace: https://gist.github.com/4564489
Fourier transform: http://nbviewer.ipython.org/urls/raw.github.com/rjw57/mintey...
Sharp edges in an image have high frequency components, just like a sharp transition in an audio signal. Filtering the high frequencies will blur the image, while filtering low frequencies will enhance edges.
This is very oversimplified, but will hopefully give you a bit of an idea. I encourage people to learn more about Fourier theory, because it explains a lot.
One introductory page that you may find useful is: http://cns-alumni.bu.edu/~slehar/fourier/fourier.html
"Please post the Visual Basic codes for this. The language you post in the article is not Visual Basic.
Thank you."
xD God !
If it is sarcasm this guy nailed it. Looks like half my inbox.
It really makes me wish for some kind of federated comments system or unique username so I can go out and find more of his work!
Unfortunately I can't make the distinction, and I think it's most likely the commenter was serious
This code does not take a swirled image and solve it. It takes a set of images with various swirl levels and finds the one with shortest sum of edge lengths.
The code does not do any un-swirling of the image. It also uses external libraries to convert to grayscale, apply the Sobel filter and the sum of edges.
I other words, it is far from breaking the swirled CAPTCHA in 23 lines of Python. If you had to write the un-swirling, gray-scaling, Sobel filtering and summation code in Python you'd be looking at a much larger pile-o-code.
The demo and the intent is good. I just wish the title didn't say "23 lines of". I don't think the article would have suffered at all if the title was "Breaking the MintEye image CAPTCHA with Python".
Again, the intent and what is being demonstrated are excellent. The title, in my not-so-humble opinion, is hugely misleading.
Except it does break the captcha in 23 lines. I don't get your point.
Why would he need to do any 'un-swirling' in the first place? That's not the point of the captcha. The captcha provides you with multiple images and you have to pick the least swirled one - which is exactly what his code does.
And you argue that because he did use external libraries it's not 23 lines of python. Of course it is. He had to write only 23 lines that make up the logic to break the captcha. If you'd argue that one would have to add any previous work (or lines) done by other people to the linecount of your own project, I could also argue that 'print("Hello")' is not one line of python, because it uses some standard python library, which in turn calls native code, that native code would make a few syscalls and at some point resulting in multiple hundred lines of compiled kernel C code being executed.
So the linecount of his 23 lines python script would actually be: 23 lines of python + various libraries + the entire Linux kernel = roughly 20 million lines of code. Good job.
And yes, that was nitpicking. And I'm angry for some reason.
When someone publishes code and says something like "solved <problem> in <n lines> of <pick your language>" there generally is an implied "my language is better than yours" subliminal message that, for some strange reason, is based on line count.
Let's not debate the merit of line count as a measure of how good a language may or may not be. If we are going to go there I'll write the same solution in APL and we'll start counting characters instead. Again, line or character count, in my opinion, is not a measure of the "superiority" of a language.
The 28 line solution is not pure Python. How do we define pure Python. Let's just say that "solved <problem> in <n lines> of Python" to me means that you download and install Python:
http://www.python.org/download/releases/2.7.3/
Install nothing else whatsoever and write code that solves <problem>.
OpenCV, which is what the author used for a couple of aspects of this code, is an extensive (and really cool) C++ library that is being accessed from Python. Here's the source:
https://github.com/Itseez/opencv
I'll leave it up to the reader to find the source for the Sobel method.
A much more honest title could have included something like "solving <problem> with <n> lines of Python using OpenCV".
As I said before, the intent of the article and what is being demonstrated are good, no, great. I just wish the title was a little more reflective of reality. That's all. No need to get worked-up. This is not that serious of an issue. Just a comment.
I agree with him. If it's wrapped up in a library and it's distributed by a package manager then it doesn't count towards the total SLOC of your project.
> If you had to write the un-swirling, gray-scaling, Sobel filtering and summation code in Python you'd be looking at a much larger pile-o-code
I would also like to point out these are also all very simple operations, which would only take a few lines of Python/C/whatever to do. Python just happens to have a pre-written libraries to save reinventing the wheel.
Yikes! They are not. That's a lot of code. I've done a ton of image processing work in both hardware (FPGA) and software (various languages). Swirling, gray-scaling, Sobel filtering and summation collectively are far from "a few lines of Python/C/whatever to do"
> Python just happens to have a pre-written libraries to save reinventing the wheel
That's not true. OpenCV is NOT a Python library, it's nearly 100% C++ as far as I can tell:
https://github.com/Itseez/opencv
That was, in many ways, my point. This is not a solution in 23 lines of Python. Go install Python from Python.org --and NOTHING ELSE-- and solve the problem. Let's see how many lines of Python it takes.
There's nothing wrong with the intent of the author in terms of showing how one can break these CAPTCHA's using edge-length evaluation. I never put any thought into this myself so, yes, I learned something of value from his post. I just wish the title was more genuine, that's all.
Simple. To go along the lines of your example:
Headline: "Microsoft Word written in 50 lines of Python".
Reality:
The fifty lines of Python do nothing more than call a set of Microsoft libraries written in C and C++ that, well, result in MS Word.
Did the author really write MS Word in 50 lines of Python?
Of course not. It would be absolutely insane to even suggest the idea that this could even approach a valid metric.
Nope, the author simply made use of external non-Python libraries that are the results of probably hundreds of thousands of lines of code and many man-years of work. He does not, for even a microsecond, get to claim that he wrote MS Word in 50 lines of Python.
That's my point. Is it a little bit clearer now?
Again, unless you write the entire stack from the bottom up, you're always depending on vast amounts of code you didn't write. So what's the difference?
What's the replacement? Tying every account to a mobile phone or credit card?
That's a stupid idea, based on some weird assumption that it's somehow safe to give access to your system for a user, but not for a robot. If the only thing stopping people from messing your system is automation, you should rethink it from the get go.
But wouldn't an obvious answer to this be to use a background full of swirl, then add people onto it, then swirl again (so the background swirl is swirled twice).
Then when you'd be "deswirling" with you code, you'll be finding something always swirled?
maybe even use a background who's "swirled right" and then "swirl left" the "backgroung + people" (or nyan cat or whatever)?
It wouldn't change what he is detecting, which is the sum of the edges.