void body(Parameters param, MultibandKernel **kernels1, MultibandKernel **kernels2, MultibandKernel **kernels3) /*int filterSize, int n, int n2, int n3, int stride, float radio, float alpha, int activation, MultibandKernel **kernels1, MultibandKernel **kernels2, MultibandKernel **kernels3, int normalizationSize)*/ { int aux = 0; char c; char filename[200]; //Read image MultibandImage *im; MultibandImage *layer_result; #pragma omp critical { while((c=getchar()) && c!='\n' && c!=EOF) filename[aux++] = c; filename[aux] = '\0'; } im = ReadGrayImageIntoMultibandImage(filename); //Layer 0 layer_result = layer0(im, param.nz_c1); DestroyMultibandImage(&im); im = layer_result; //Layer 1 layer_result = layer_n(im, param.fn_c1, 1, kernels1, param.activation, param.stride, param.pz_c1, param.alpha, param.nz_c1); DestroyMultibandImage(&im); im = layer_result; //Layer 2 layer_result = layer_n(im, param.fn_c2, param.fn_c1, kernels2, param.activation, param.stride, param.pz_c2, param.alpha, param.nz_c2); DestroyMultibandImage(&im); im = layer_result; //Layer 3 layer_result = layer_n(im, param.fn_c3, param.fn_c2, kernels3, param.activation, param.stride, param.pz_c3, param.alpha, param.nz_c3); DestroyMultibandImage(&im); im = layer_result; //Write result #pragma omp critical { Write2CSV(&im, 1, "result.csv", filename); } //Destroy DestroyMultibandImage(&im); }
int main(int argc, char** argv) { char c; int i, aux; char filename[200]; int filterSize = 3; int n = 64; int n2 =128; int n3 =256; int stride = 2; float radio = 2; float alpha = 10; int activation = ACTIVATION_MAX; int times = 0; //Generate Random Filter Banks MultibandKernel **kernels1 = generateKernelBank(filterSize,filterSize,1,n); MultibandKernel **kernels2 = generateKernelBank(filterSize,filterSize,n,n2); MultibandKernel **kernels3 = generateKernelBank(filterSize,filterSize,n2,n3); printf("Created Multiband Kernels for convolution\n"); //Read image MultibandImage *im; MultibandImage *layer_result; printf("Started bucle\n"); while(1){ aux = 0; times++; while((c=getchar()) && c!='\n') filename[aux++] = c; filename[aux] = '\0'; if(strcmp(filename, "END")==0) break; printf("Image %d\n", times); im = ReadGrayImageIntoMultibandImage(filename); //Layer 0 layer_result = layer0(im); DestroyMultibandImage(&im); im = layer_result; //Layer 1 layer_result = layer_n(im, n, 1, kernels1, activation, stride, radio, alpha); DestroyMultibandImage(&im); im = layer_result; //Layer 2 layer_result = layer_n(im, n2, n, kernels2, activation, stride, radio, alpha); DestroyMultibandImage(&im); im = layer_result; //Layer 3 layer_result = layer_n(im, n3, n2, kernels3, activation, stride, radio, alpha); DestroyMultibandImage(&im); im = layer_result; //Write result Write2CSV(&im, 1, "result.csv", filename); //Destroy DestroyMultibandImage(&im); } for(i=0; i<n; i++){ DestroyMultibandKernel(&kernels1[i]); } for(i=0; i<n2; i++){ DestroyMultibandKernel(&kernels2[i]); } for(i=0; i<n3; i++){ DestroyMultibandKernel(&kernels3[i]); } free(kernels1); free(kernels2); free(kernels3); /*struct stat st = {0}; if (stat("directorioPrueba", &st) == -1) { if (mkdir("directorioPrueba", 0777) == -1){ Error("cannot create directory.", "WriteMultibandImageToGrayImages"); } } char name[30] = ""; char extencion[10] = ""; char file[] = "nombrearchivo.extencion"; char *ptc; ptc = strchr(file, '.'); strcpy(extencion, ptc+1); *ptc = '\0'; strcpy(name, file); printf("name: %s, ext: %s", name, extencion);*/ return 0; }