Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
int f;
for (f = 10; f < 13; f++)
{
int i, j, k;
ccv_convnet_layer_t *layer = convnet->layers + f;
char filename[256];
float kmean[256];
sprintf(filename, "lut-layer-%d.txt", f);
FILE *r = fopen(filename, "r");
for (i = 0; i < 0x100; i++)
{
union {
int i;
float f;
} v;
fscanf(r, "%d %d", &j, &v.i);
kmean[i] = v.f;
}
fclose(r);
for (i = 0; i < 0x100; i++)
{
k = i;
for (j = i + 1; j < 0x100; j++)
if (kmean[j] < kmean[k])
k = j;
float t = kmean[k];
kmean[k] = kmean[i];
kmean[i] = t;
}
ccv_dense_matrix_t* pngw = 0;
sprintf(filename, "layer-%d-crush.png", f);
ccv_read(filename, &pngw, CCV_IO_ANY_FILE | CCV_IO_GRAY);
for (i = 0; i < pngw->rows; i++)
for (j = 0; j < pngw->cols; j++)
layer->w[i * pngw->cols + j] = kmean[pngw->data.u8[i * pngw->cols + j]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment