Browse Source

* print colour count in debug messages

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@402 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 20 years ago
parent
commit
82ff580894
3 changed files with 29 additions and 2 deletions
  1. +1
    -0
      src/common.h
  2. +22
    -0
      src/filters.c
  3. +6
    -2
      src/main.c

+ 1
- 0
src/common.h View File

@@ -45,4 +45,5 @@ struct image *filter_trick(struct image *img);
struct image *filter_smooth(struct image *img);
struct image *filter_median(struct image *img);
struct image *filter_contrast(struct image *img);
int filter_count(struct image *img);


+ 22
- 0
src/filters.c View File

@@ -329,3 +329,25 @@ struct image *filter_contrast(struct image *img)
return dst;
}

int filter_count(struct image *img)
{
int histo[256];
int x, y, i, count = 0;
int r, g, b;

for(i = 0; i < 256; i++)
histo[i] = 0;

for(y = 0; y < img->height; y++)
for(x = 0; x < img->width; x++)
{
getgray(img, x, y, &r);
histo[r] = 1;
}

for(i = 0; i < 256; i++)
count += histo[i];

return count;
}


+ 6
- 2
src/main.c View File

@@ -108,6 +108,7 @@ int main(int argc, char *argv[])
{
char *input = argv[optind], *result;
struct image *img;
int count;

img = image_load(argv[optind]);
if(!img)
@@ -117,7 +118,9 @@ int main(int argc, char *argv[])
continue;
}

dprintf("image size %ix%i\n", img->width, img->height);
count = filter_count(img);
dprintf("image size %ix%i, %i colours\n",
img->width, img->height, count);

if(!strcmp(mode, "test"))
result = decode_test(img);
@@ -134,7 +137,8 @@ int main(int argc, char *argv[])
dprintf("autodetecting phpBB captcha\n");
result = decode_phpbb(img);
}
else if(img->height == 25 || img->height == 30)
else if((img->height == 25 || img->height == 30)
&& count < 10)
{
dprintf("autodetecting scode captcha\n");
result = decode_scode(img);


Loading…
Cancel
Save