Change images aspect ration

This commit is contained in:
augustin64 2022-11-19 22:22:24 +01:00
parent 66e302d6c1
commit 18900f3fe9
2 changed files with 12 additions and 5 deletions

View File

@ -7,12 +7,19 @@
void print_image(unsigned char* image, int height, int width) { void print_image(unsigned char* image, int height, int width) {
int red, green, blue;
for (int i=0; i < (int)height/2; i++) {
for (int j=0; j < (int)width; j++) {
red = (image[((2*i*width)+j)*3 + 0] + image[(((2*i+1)*width)+j)*3 + 0])/2;
green = (image[((2*i*width)+j)*3 + 1] + image[(((2*i+1)*width)+j)*3 + 1])/2;;
blue = (image[((2*i*width)+j)*3 + 2] + image[(((2*i+1)*width)+j)*3 + 2])/2;;
for (int i=0; i < (int)width; i++) { // Make the text color opposed to background color
for (int j=0; j < (int)height; j++) { printf("\x1b[38;2;%d;%d;%dm", 255-red, 255-green, 255-blue);
printf("\x1b[38;2;%d;%d;%dm#\x1b[0m", image[((i*width)+j)*3 + 0], image[((i*width)+j)*3 + 1], image[((i*width)+j)*3 + 2]);
printf("\x1b[48;2;%d;%d;%dm ", red, green, blue);
} }
printf("\n"); printf("\x1b[0m\n");
} }
} }

View File

@ -67,7 +67,7 @@ void* train_thread(void* parameters) {
} }
write_image_in_network_260(param->dataset->images[i], height, width, network->input[0]); write_image_in_network_260(param->dataset->images[i], height, width, network->input[0]);
forward_propagation(network); forward_propagation(network);
maxi = indice_max(network->input[network->size-1][0][0], 10); maxi = indice_max(network->input[network->size-1][0][0], param->dataset->numCategories);
backward_propagation(network, param->dataset->labels[i]); backward_propagation(network, param->dataset->labels[i]);
if (maxi == (int)param->dataset->labels[i]) { if (maxi == (int)param->dataset->labels[i]) {