Created
September 10, 2017 02:48
-
-
Save shumon84/018b3c08b87e5e1948ee77ddc2bb9a50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include"image.h" | |
double ratio(image_t *img,int y,int x) | |
{ | |
int unitH=img->height/5; | |
int unitW=img->width/24; | |
int sum=0; | |
int i,j; | |
int n=unitH*(y+1); | |
int m=unitW*(x+1); | |
for(i=unitH*y;i<n;i++) | |
for(j=unitW*x;j<m;j++) | |
if(img->map[i][j].g>127)sum++; | |
return (double)sum/(unitH*unitW); | |
} | |
int main() | |
{ | |
char w[4][24]= | |
{ | |
{"01!2\"3#4$5%6&7'8(9)-=^~\\"}, | |
{"|qQwWeErRtTyYuUiIoOpP@`["}, | |
{"{aAsSdDfFgGhHjJkKlL;+:*]"}, | |
{"}zZxXcCvVbBnNmMmM <.>/?_"}, | |
}; | |
image_t* img=read_png_file("word.png"); | |
image_to_gray(img); | |
int i,j; | |
for(i=0;i<4;i++) | |
for(j=0;j<24;j++) | |
printf("{'%c',%f,},\n",w[i][j],ratio(img,i,j)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment