int main(int argc, char **argv) { int letarr[11],i=0,j=0,count=0; char buf[MAXLENGTH]; char *p=buf; for(i=0;i<11;i++) { letarr[i]=0; } if(argc != 2) { printf("Usage ./a.out <filename>"); exit(1); } FILE *fp = fopen(argv[1], "r"); if(fp == NULL) { printf("File could not be opened"); exit(2); } while(fgets(p, MAXLENGTH, fp)) { for(j=0;*(p+j)!='\0';j++) { if(*(p+j)==' '||*(p+j)==','||*(p+j)=='\t'||*(p+j)=='.'||*(p+j)=='\n') { letarr[count]++; count=0; continue; } else { count++; } if(*(p+j+1)=='\0') letarr[count-1]++; } } printf("_____________________\n"); printf("|Alphabets|Frequency|\n"); printf("_____________________\n"); for(i=3;i<10;i++) { printf("|%d |%d |\n",i,letarr[i]); printf("_____________________\n"); } printf("|10 |%d |\n",letarr[10]); printf("_____________________\n"); printf(" The Vertical Histogram\n"); printf(" ----------------------\n"); verHist(letarr,11); printf("\n"); printf(" The Horizontal Histogram\n"); printf(" -----------------------\n"); printf("|\n"); histoGram(letarr,11); fclose(fp); return 0; }
void TextLocation:: checkBox(IplImage* src, CvRect &box) { vector<int> verHist(0); getVerHistByRect(src, box, verHist); clearifyHist(verHist, 40); plot1DHisto(verHist, verHist.size()/2, "box verhist"); verCut(verHist, box); vector<int> horHist(0); getHorHistByRect(src, box, horHist); clearifyHist(horHist, 10); plot1DHisto(horHist, horHist.size() / 2, "box horhist"); horCut(horHist, box); }