traffic_count/image_filtering_debugging_C/edgeDetector.c
void readImage (char *filename, unsigned char *inputImage, unsigned char *header, unsigned int *height, unsigned int *width)
{
    FILE *inputFile;
    int i, r;
    *width = 0;
    *height = 0;
    if (inputFile = fopen (filename, "rb")) {
        fread (header, sizeof (unsigned char), HEADER_LEN, inputFile);
        *width = * ((unsigned int *) (header + WIDTH_POS));
        *height = * ((unsigned int *) (header + HEIGHT_POS));
        r = fread (inputImage, sizeof (unsigned char), (*width) * (*height) * DEPTH, inputFile);
        if (r != sizeof (unsigned char) * (*width) * (*height)*DEPTH)
            printf ("Error while reading image\n");
        /*the commented code is used for computing the negative image*/
        /*for(i=0;i<(*height)*(*width)*DEPTH;i++){
         *(inputImage+i)=255-*(inputImage+i);
           }*/
        fclose (inputFile);
    }
    else {
        printf ("Error while opening input file\n");
    }
}
/*Load an image from the specified file. It returns the grid of RGB pixels, its height and widht and the array of the image header data*/
Load an image from the specified file. It returns the grid of RGB pixels, its height and widht and the array of the image header data
Load an image from the specified file . It returns the grid of RGB pixels its height and widht and the array of the image header data
void readImage (char *filename, unsigned char *inputImage, unsigned char *header, unsigned int *height, unsigned int *width)
{
    FILE *inputFile;
    int i, r;
    *width = 0;
    *height = 0;
    if (inputFile = fopen (filename, "rb")) {
        fread (header, sizeof (unsigned char), HEADER_LEN, inputFile);
        *width = * ((unsigned int *) (header + WIDTH_POS));
        *height = * ((unsigned int *) (header + HEIGHT_POS));
        r = fread (inputImage, sizeof (unsigned char), (*width) * (*height) * DEPTH, inputFile);
        if (r != sizeof (unsigned char) * (*width) * (*height)*DEPTH)
            printf ("Error while reading image\n");
        fclose (inputFile);
    }
    else {
        printf ("Error while opening input file\n");
    }
}
void readImage ( char * filename , unsigned char * inputImage , unsigned char * header , unsigned int * height , unsigned int * width ) { FILE * inputFile ; int i , r ; * width = 0 ; * height = 0 ; if ( inputFile = fopen ( filename , " " ) ) { fread ( header , sizeof ( unsigned char ) , HEADER_LEN , inputFile ) ; * width = * ( ( unsigned int * ) ( header + WIDTH_POS ) ) ; * height = * ( ( unsigned int * ) ( header + HEIGHT_POS ) ) ; r = fread ( inputImage , sizeof ( unsigned char ) , ( * width ) * ( * height ) * DEPTH , inputFile ) ; if ( r != sizeof ( unsigned char ) * ( * width ) * ( * height ) * DEPTH ) printf ( " \n " ) ; fclose ( inputFile ) ; } else { printf ( " \n " ) ; } }
Load an image from the specified file.
Load an image from the specified file .
/*the commented code is used for computing the negative image*/ /*for(i=0;i<(*height)*(*width)*DEPTH;i++){
         *(inputImage+i)=255-*(inputImage+i);
           }*/