Last active
August 29, 2015 14:04
-
-
Save liuliu/9c737fa53a62d7165f2c 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
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