a little hint for the darkest pixel method: I found it to work better with a little weirdness added to the method (don't make stats myself tho, but with the normal darkest pixel it failed quite often):
yeah, it's JS, sue me
var w = this.captcha.width;
var h = this.captcha.height;
this.canvas.width = w;
this.canvas.height = h;
var context = this.canvas.getContext("2d");
context.drawImage(this.captcha,0,0,w,h);
var data = context.getImageData(0,0,w,h).data; // height*width*RGBA
// find highest luminance of downscaled inversion
var image = new Array;
for(var i = 0; i+1 < h; i+=2)
{
for(var j = 0; j+1 < w; j += 2)
{
var r = 0;
var g = 0;
var b = 0;
for(var n = 0; n < 4; n++)
{
var start = 4*(j+(n%2)+(i+Math.floor(n/2))*w);
r += data[start];
g += data[start+1];
b += data[start+2];
}
r = 256 - r/4;
g = 256 - g/4;
b = 256 - b/4;
image.push(new Coord(j,i,(new Color(r,g,b,1)).Luminance()));
}
}
image.sort(function(a,b) { return (a.v - b.v); });
// highest luinance one is our candidate
this.target = image.pop();
so in a nutshell: I take the image downscaled by 2 in both directions and take the average of all 4 "source pixels" as input - this seemed to yield a lot better results than working on the image itself
also luminance isn't really luminance, it's just the average of the rgb values (could also use sum)
Edited by DoNotAnnoyMe, 29 March 2012 - 01:22 AM.