/*
    This file was generated by the command

       cfunctions similar-image.c

    at 19:50:15 on Tuesday 23 February 2016, local time.
*/
#ifndef CFH_SIMILAR_IMAGE_H
#define CFH_SIMILAR_IMAGE_H

/* From 'similar-image.c': */

#line 10 "similar-image.c"
#define SIZE 9
#define DIRECTIONS 8
typedef struct point {
    double average_grey_level;
    int d[DIRECTIONS];
}
point_t;
typedef struct simage {
    /* The width of the image in pixels. */
    unsigned int width;
    /* The height of the image in pixels. */
    unsigned int height;
    /* The image data. */
    unsigned char * data;
    /* The P-value for this image, see equation in article. */
    unsigned int p;
    /* The grid of values. */
    point_t grid[SIZE*SIZE];
    /* width / (SIZE + 1) */
    double w10;
    /* height / (SIZE + 1) */
    double h10;
    /* This contains a true value if we have actually loaded image
       data, or a false value if not. This may be false if we just
       loaded a signature rather than the image. */
    unsigned int valid_image : 1;
/* The grid is already filled. */
    unsigned int grid_filled : 1;
}
simage_t;
typedef enum {
    simage_ok,
    /* malloc failed. */
    simage_memory_failure,
    /* x or y is outside the image dimensions. */
    simage_status_bounds,
    simage_status_bad_image,
    /* Some upstream program did a stupid thing. */
    simage_status_bad_logic,
}
simage_status_t;
typedef enum {
    much_darker = -2,
    darker = -1,
    same = 0,
    lighter = 1,
    much_lighter = 2,
}
comparison_t;

#line 95 "similar-image.c"
int x_y_to_entry (int x , int y );

#line 113 "similar-image.c"
simage_status_t simage_dump (simage_t * s );

#line 125 "similar-image.c"
simage_status_t simage_init (simage_t * s , unsigned int width , unsigned int height );

#line 154 "similar-image.c"
simage_status_t simage_free (simage_t * s );

#line 163 "similar-image.c"
simage_status_t simage_set_pixel (simage_t * s , int x , int y , unsigned char grey );

#line 171 "similar-image.c"
simage_status_t simage_fill_entry (simage_t * s , int i , int j );

#line 224 "similar-image.c"
simage_status_t simage_fill_entries (simage_t * s );

#line 246 "similar-image.c"
int xo_yo_to_direction (int xo , int yo );

#line 260 "similar-image.c"
simage_status_t direction_to_xo_yo (int direction , int * xo , int * yo );

#line 290 "similar-image.c"
int diff (int thisgrey , int thatgrey );

#line 319 "similar-image.c"
simage_status_t simage_make_point_diffs (simage_t * s , int x , int y );

#line 365 "similar-image.c"
simage_status_t entry_to_x_y (int entry , int * x_ptr , int * y_ptr );

#line 379 "similar-image.c"
simage_status_t simage_make_differences (simage_t * s );

#line 394 "similar-image.c"
simage_status_t simage_check_image (simage_t * s );

#line 410 "similar-image.c"
simage_status_t simage_fill_grid (simage_t * s );

#line 425 "similar-image.c"
simage_status_t simage_diff (simage_t * s1 , simage_t * s2 , double * total_diff );

#line 460 "similar-image.c"
int inside (int cell , int direction );

#line 479 "similar-image.c"
simage_status_t simage_signature (simage_t * s , char ** signature_ptr , int * signature_length );

#line 514 "similar-image.c"
simage_status_t simage_free_signature (char * signature );

#line 522 "similar-image.c"
simage_status_t simage_fill_from_signature (simage_t * image , char * signature , int signature_length );

#endif /* CFH_SIMILAR_IMAGE_H */
