/************************************************************************** C O N T O U R M A P . C ***************************************************************************/ /***************************************************************************** FILENAME : contourmap.c PURPOSE : Contour mapping Functions *****************************************************************************/ #include #include #include #include #include "isthdefs.h" #include "piece.h" #include #include extern int threshold; /* added RWW 9/9/90 */ extern struct timeval f; extern int oldsec; extern int image[512][512]; extern int inverse_isthmus; extern int no_circle; extern int file_create; extern int currpiece; extern int camera; extern char strg[79]; extern int deltax, deltay; int radius; int x[2500],y[2500],length; /***************************************************************************** initmat *****************************************************************************/ int initmat(minx,miny,maxx,maxy) int *minx,*miny,*maxx,*maxy; { int mx1, my1, mx2, my2; int i; int diffx, diffy; char string[80]; printit("Initializing for MAT"); if (camera) { VIS$INIT_LUTS(); /* reset luts back to default */ VIS$VIEW(); VIS$FREEZE(); threshold = VIS$OPTIMAL_THRESHOLD(*minx=100, *miny=100, *maxx=420, *maxy=400, 0, 0); sprintf (string, "optimal binary threshold is %d", threshold); printit(string); init_binarize(threshold); if (!no_circle) colors(4); else colors(11 /*20 /*35*/); VIS$FREEZE(); if (inverse_isthmus) { do_inverse(threshold); VIS$VIEW(); VIS$FREEZE(); VIS$BORDER_FOLLOW (&length,x,y,0, 255,50,150,480,350,50); VIS$GET_MAX_XY (x, y, length, &mx1, &my1, &mx2, &my2); printit("after border follow"); *minx = mx1 - 5; *miny = my1 - 5; *maxx = mx2 + 5; *maxy = my2 + 5; for (i=40;i<=55;i++) VIS$DRAW_BOX (*minx, *miny, *maxx, *maxy, 0 /*255*/, i); *minx = *minx - 45; *miny = *miny - 45; *maxx = *maxx + 45; *maxy = *maxy + 45; } } else { redscrn(); printit("starting to read file"); VIS$SELECT_LUT(0,0); VIS$SELECT_LUT(1,0); VIS$SELECT_LUT(2,0); VIS$SELECT_LUT(3,0); sprintf(strg,"piece%d.image",currpiece); read_picture(0, 0, strg); printit("Done reading picture "); if (!no_circle) return(0); else colors(11 /*20 /*35*/); if (inverse_isthmus) { do_inverse(threshold); VIS$SET_MODE(1); freeze(); for (i=20;i<=35;i++) VIS$DRAW_BOX (*minx, *miny, *maxx, *maxy, 0, i); *minx = *minx - 25; *miny = *miny - 25; *maxx = *maxx + 25; *maxy = *maxy + 25; } else { init_binarize(threshold); VIS$SET_MODE(1); VIS$SNAP(); } printit("Done real time freeze"); } if (!inverse_isthmus) /* Positive Isthmus */ { radius = RADIUS /* used these before 150 /*36 /*18 /*91*/; if (!no_circle) VIS$FILL_CIRCLE(310,220, radius,1); VIS$BORDER_FOLLOW (&length,x,y,1, 255,100,150,480,300,20); VIS$GET_MAX_XY (x, y, length, &mx1, &my1, &mx2, &my2); *minx = mx1 - 5; *miny = my1 - 5; *maxx = mx2 + 5; *maxy = my2 + 5; diffx = *maxx - *minx; diffy = *maxy - *miny; sprintf (strg, "%d x %d", diffx, diffy); printit (strg); VIS$DRAW_BOX (*minx, *miny, *maxx, *maxy, BOXCOLOR, 15); #ifdef ROGER alph( strg, 'b', *maxx+20, (*maxy + *miny)/2 ); sprintf (strg, "object's border"); alph( strg, 'b', 150, 50 ); waitforkey(); #endif } } /* end function */ timing_info (before) int before; { int r, total_time; char string[80]; if (before) { r = gettimeofday(&f); oldsec = f.tv_sec; } else { r = gettimeofday(&f); total_time = f.tv_sec - oldsec; sprintf (string, "total time is %d in seconds only", total_time); printit(string); waitforkey(); return (total_time); } } /* end function */ /***************************************************************************** E N D P R O G R A M *****************************************************************************/