#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ROWS 480
#define COLS 640
#define PI 3.14159265358979323846
#define sqr(x) ((x)*(x))
void clear( unsigned char image[][COLS] );
void header( int row, int col, unsigned char head[32] );
int main( int argc, char** argv )
{
int i,j, sgmmax;
// localmax: number in the three bucket of voting array corrsponding to
three local maxima
// index[3][2]: used for store rho and theta
int dedx, dedy, sgm, localmax[3] = {0, 0, 0}, index[3]
[2] = { 0, 0, 0, 0, 0, 0 }, ma;
// voting; voting array
int sgm_threshold, hough_threshold, voting[][];
FILE* fp;
unsigned char image[ROWS][COLS], simage[ROWS][COLS], sgmimage[ROWS]
[COLS], bimage[ROWS][COLS], head[32];
char filename[50], ifilename[50];
float theta, rho;
clear(simage);
strcpy ( filename, "image.raw");
memset ( voting, 0, sizeof(int) * 180 * 400 );
header(ROWS, COLS, head);
/* Read in the image */
if (!( fp = fopen(filename, "rb" ) ))
{
fprintf( stderr, "error: couldn't open %s\n", argv[1]);
exit(1);
}
for ( i = 0 ; i < ROWS ; i++ )
if (!( COLS == fread( image[i], sizeof(char), COLS, fp ) ))
{
fprintf( stderr, "error: couldn't read %s\n", argv[1] );
exit(1);
}
fclose(fp);
/* Compute SGM */