Skip to content

Commit

Permalink
fix a horrible bug where the pixels were treated as signed values
Browse files Browse the repository at this point in the history
  • Loading branch information
bbawj committed Mar 2, 2024
1 parent db43ba0 commit 821023f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion common.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ Mat init_train_set(char *img_data, char *label_data, int n_images) {
for (int row = 0; row < IMG_HEIGHT; ++row) {
for (int col = 0; col < IMG_WIDTH; ++col) {
float pixel =
img_data[image * IMG_SIZE + row * IMG_WIDTH + col] / 255.0f;
(unsigned char)
img_data[image * IMG_SIZE + row * IMG_WIDTH + col] /
255.0f;
MAT_AT(t, image, row * IMG_WIDTH + col) = pixel;
}
}
Expand Down

0 comments on commit 821023f

Please sign in to comment.