What i have so far is a nice and rapid algorithm for finding the pixel dominant from bmp image.I am not sure how to make it to work.. i though it works, but the program freezes.RGBbitfox_get_primecolor_direct(char *FILE_NAME){    RGB primecolor;    BYTE rgb[3];    dword *counts = calloc(pow(256, 3), sizeof(*counts));    dword max_count = 0;    FILE* fp = fopen(convert(FILE_NAME), rb);    fseek(fp, 54, SEEK_SET);    while (fread (rgb, sizeof(BYTE), 3, fp) != EOF)    {        dword idx = (((dword)rgb[0]) << 16) | (((dword)rgb[1]) << 8) | (dword)rgb[2];        if (++counts[idx] > max_count) max_count = idx;    }    primecolor.R = (max_count >> 16) & 0xFF;    primecolor.G = (max_count >> 8) & 0xFF;    primecolor.B = max_count & 0xFF;    free(counts);    fclose(fp);    return primecolor;}BYTE is unsigned charRGB is struct containg BYTE R, G and B.
Function to get the most frequently appearing pixel
c;image;io