Live data from Hacker News

Breaking the MintEye image CAPTCHA in 23 lines of Python

jwandrews.co.uk

41–50 of 60 posts

Re: Breaking the MintEye image CAPTCHA in 23 lines of Python

#41
post #23
post #19

For those interested, the minteye captcha has been broken by other methods as well. 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...

Could someone explain the general idea behind using FFT in these situations (excusing my ignorance)? I recall it from my university days but that was completely out of context. I know you can use it to decompose audio signals into frequency components, I don't understand how it applies to images though.

[deleted]

Re: Breaking the MintEye image CAPTCHA in 23 lines of Python

#42

Earlier quoted context omitted.

Well put. The title is indeed completely factual! Including '23 lines' was just to let people know at first glance that the solution is simple. > 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…

> 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. 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 happe…

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.

Re: Breaking the MintEye image CAPTCHA in 23 lines of Python

#43

Earlier quoted context omitted.

>it is far from breaking the swirled CAPTCHA in 23 lines of Python 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…

No need to be angry. None of this is going to remove food from your table or affect your life in any way whatsoever. Take it easy. I am just opening the topic for conversation. We can discuss things without pulling out semi-automatic weapons, right? When someone publishes code and says something like "solved in of " there generally is an implied "my language is better than yours" subliminal message that, for some str…

Someone has disagreed with you -- which you anticipated would happen. Therefore he must be angry?

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.

Re: Breaking the MintEye image CAPTCHA in 23 lines of Python

#44
post #43

Earlier quoted context omitted.

No need to be angry. None of this is going to remove food from your table or affect your life in any way whatsoever. Take it easy. I am just opening the topic for conversation. We can discuss things without pulling out semi-automatic weapons, right? When someone publishes code and says something like "solved in of " there generally is an implied "my language is better than yours" subliminal message that, for some str…

Someone has disagreed with you -- which you anticipated would happen. Therefore he must be angry? 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.

Read the last line of his post please. He said he was angry, no me.

>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.

Think about what you are saying. With that logic I can write a library in C++ that evaluates all images in the current working directory for least edge length and returns the name or index of the winning file. My Python program, then, might look something like this:

    import magic
    print magic.evaluate()
And then I claim that I have written a program that solves a swirly CAPCHA in two lines of Python.

C'mon.

I you want to count true Python lines, download the language from python.org and write a solver without the use of any add-on libraries. Then we can talk about Python lines.

Re: Breaking the MintEye image CAPTCHA in 23 lines of Python

#45

Earlier quoted context omitted.

> 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. 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 happe…

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 the…

Show me working code and then we can talk. :)

Oh, BTW, "V = r x g x b/3" is incorrect. This is not you convert a color image to a grayscale image.

Re: Breaking the MintEye image CAPTCHA in 23 lines of Python

#46

Earlier quoted context omitted.

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 the…

Show me working code and then we can talk. :) Oh, BTW, "V = r x g x b/3" is incorrect. This is not you convert a color image to a grayscale image.

[deleted]

Re: Breaking the MintEye image CAPTCHA in 23 lines of Python

#47
post #40

This is nitpicking. Well, maybe not. 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 o…

And if you had to write the OS it runs on you'd have a really huge "pile-o-code". What's your point?

> What's your point?

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?

Re: Breaking the MintEye image CAPTCHA in 23 lines of Python

#48

Earlier quoted context omitted.

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 the…

Show me working code and then we can talk. :) Oh, BTW, "V = r x g x b/3" is incorrect. This is not you convert a color image to a grayscale image.

Ok, I'll do. I will assume that we already have the image in an 1-dimensional array, each element containing an array of the RGB values. Then we can convert it to grayscale with one line of python.

    gray = map(lambda p:sum(p)/3,IMG)
If you want to test it, you can use this 3x3 sample image (or just load one):

    IMG = [[5, 5, 5], [6, 8, 9], [94, 123, 4], [54, 5, 32], [44, 3, 3], [34, 234, 33], [5, 5, 5], [6, 8, 9], [94, 123, 4]]
The result will look like this:

    [5, 7, 73, 30, 16, 100, 5, 7, 73]
If your image happens to be loaded into a 2-dimensional array, use this:

    gray = map(lambda row:map(lambda p:sum(p)/3,row), IMG)
Sobel is slightly more complicated, but can be written like this (you'll need a larger sample image though):

    width, height #width and height of our image
    IMG           #2D array of our RGB values
    sobel         #result image
    # The actual filter starts here:
    for x in range(1,width-1):
        for y in range(1,height-1):
			sx = IMG[x-1][y-1]+IMG[x][y-1]*2+IMG[x+1][y-1]-IMG[x-1][y+1]-IMG[x][y+1]*2-IMG[x+1][y+1]
			sy = IMG[x+1][y-1]+IMG[x+1][y]*2+IMG[x+1][y+1]-IMG[x-1][y-1]-IMG[x-1][y]*2-IMG[x-1][y+1]
			sobel[x][y] = Math.sqrt(sx*sx+sy*sy)
A total of 5 lines. And I have to thank you, because I finally just learned what convolutions are while doing this.

Re: Breaking the MintEye image CAPTCHA in 23 lines of Python

#49
post #43

Earlier quoted context omitted.

Someone has disagreed with you -- which you anticipated would happen. Therefore he must be angry? 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.

Read the last line of his post please. He said he was angry, no me. >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. Think about what you are saying. With that logic I can write a library in C++ that evaluates all images in the current working directory for least edge length and returns the name or index of the winning file. My Py…

http://www.jwandrews.co.uk/2013/01/breaking-the-minteye-imag...

OK, I didn't write the JPEG decoder, but how far do you want me to go?!

Re: Breaking the MintEye image CAPTCHA in 23 lines of Python

#50

Earlier quoted context omitted.

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 the…

Show me working code and then we can talk. :) Oh, BTW, "V = r x g x b/3" is incorrect. This is not you convert a color image to a grayscale image.

Sorry, it was late!
Post reply on HN