/************************************************************************** M A T D R I V E R . C ***************************************************************************/ /*************************************************************************** FILENAME : matdriver.c PURPOSE : Driver for medial axis functions ***************************************************************************/ #include #include #include #include "statline.h" #include "isthdefs.h" extern WINDOW *funcwin; extern int inverse_isthmus; extern int draw_is_on;; int lut_rww = NO; int threshold; /* RWW 9/9/90 */ int row,col; int topf = 5; /* top of function window commands */ int botf = 16; /* bottom of function window commands */ int quit,i; int maxgreyy,maxgrey; int flagit; /* a flag for initialization of MAT functions. This variable is used to flag function calls before initialization */ int minx,miny,maxx,maxy; /* minimun and maximum points of image found by findtarget in initmat(). */ char string[79]; /************************************************************************** This module supports the function menu window that allows the user to execute medial axis transformation functions. ***************************************************************************/ matdriver() { int c; quit = 0; flagit = 1; row = topf; exp_comms(); do { box(funcwin,VERTCH,HORZCH); wrefresh(funcwin); hghlite(); c = wgetch(funcwin); switch( c ) { case 'v' : set_up(); break; case 'e' : quit = 1; break; case 'l' : lut_rww = (lut_rww == YES) ? NO:YES; break; case 'p' : seltpiece(&currpiece); printstat(0,0,0); break; case SPACE: mkcalls(row); break; case ESC : if ( wgetch(funcwin) == LBRACKET ) { switch( wgetch(funcwin) ) { case UPC: mveup(); break; case DOWNC: mvedown(); break; default : BELL; break; } } break; default : BELL; break; } wrefresh(funcwin); } while ( !quit ); wstandend(funcwin); wclear(funcwin); wrefresh(funcwin); } /* end main program loop */ /*************************************************************************** This function makes the calls to the various functions to perform MAT ******************************************************************************/ mkcalls(row) int row; { char gwbuff[81]; switch( row ) { case 5 : initmat(&minx,&miny,&maxx,&maxy); #ifdef ROGER if (inverse_isthmus) { do_inverse(threshold); 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; } #endif near_and_dear_pts(minx,miny,maxx,maxy); break; case 6 : initmat(&minx,&miny,&maxx,&maxy); edm (minx,miny,maxx,maxy); break; case 7 : inverse_isthmus = 1; printstat(0,0,0); write_new_piece(currpiece); break; case 8 : break; case 9: draw_is_on = (draw_is_on == 0) ? 1:0; break; case 10 : redscrn(); match_controller(); break; case 11 : initmat(&minx,&miny,&maxx,&maxy); flagit = 0; break; case 12 : initmat(&minx,&miny,&maxx,&maxy); if (inverse_isthmus) { do_inverse(threshold); for (i=25;i<=50;i++) VIS$DRAW_BOX (minx, miny, maxx, maxy, 0, i); minx = minx - 35; miny = miny - 35; maxx = maxx + 35; maxy = maxy + 35; } classic_thin(minx,miny,maxx,maxy); break; case 13 : sprintf (string, "correlation of IDF functions"); alph( string, 'b', 70, 75 ); break; case 14 : #ifdef ROGER initmat(&minx,&miny,&maxx,&maxy); if (inverse_isthmus) { do_inverse(threshold); for (i=60;i<=75;i++) VIS$DRAW_BOX (minx, miny, maxx, maxy, 0, i); minx = minx - 67; miny = miny - 67; maxx = maxx + 67; maxy = maxy + 67; } #endif inverse_isthmus = YES; /* robot path planning */ VIS$INIT_LUTS(); /* reset luts back to default */ VIS$VIEW(); VIS$SNAP(); threshold = VIS$OPTIMAL_THRESHOLD(minx, miny, maxx, maxy, NO, 0); init_binarize(threshold); colors(11 /*20 /*35*/); sleep(1); VIS$SNAP(); if (inverse_isthmus) { do_inverse(threshold); VIS$VIEW(); VIS$SNAP(); } minx = 125; miny = 125; maxx = 325; maxy = 325; 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; near_and_dear_pts(minx,miny,maxx,maxy); #ifdef ROGER edm (minx,miny,maxx,maxy); VIS$DRAW_BOX (minx, miny, maxx, maxy, 255 /*255*/, 1); waitforkey(); newcontour(minx,miny,maxx,maxy); isthmus(minx, maxgreyy, maxx, maxy, 0); #endif break; case 15 : try_match(); break; case 16 :quit = 1; break; default : break; } /* end case */ } /* end makecalls */ /*************************************************************************** This procedure will instruct the user how to select a command to be performed. ****************************************************************************/ exp_comms() { wmove(funcwin,1,20); waddstr(funcwin," MILLERSVILLE UNIVERSITY"); wmove(funcwin,2,23); waddstr(funcwin," ROBOT VISION LAB"); wmove(funcwin,3,17); waddstr(funcwin,"MEDIAL AXIS SKELETON FUNCTIONS"); wmove(funcwin,5,2); waddstr(funcwin," DEVELOP MEDIAL AXIS TRANSFORMATION (NADBP) "); wmove(funcwin,6,2); waddstr(funcwin," DEVELOP danielson euclid MAP "); wmove(funcwin,7,2); waddstr(funcwin," Write out to data file "); wmove(funcwin,8,2); waddstr(funcwin," p -> piece select "); wmove(funcwin,9,2); waddstr(funcwin," Toggle Draw_is_on l -> lutrww toggle "); wmove(funcwin,10,2); waddstr(funcwin," MATCH CONTROLLER "); wmove(funcwin,11,2); waddstr(funcwin," Initialize - Find MAX and MIN x & y "); wmove(funcwin,12,2); waddstr(funcwin," Classic Thinning Algorithm "); wmove(funcwin,13,2); waddstr(funcwin," Print title "); wmove(funcwin,14,2); waddstr(funcwin," Robot Path Planning toggle "); wmove(funcwin,15,2); waddstr(funcwin," Try Match Currpiece "); wmove(funcwin,16,2); waddstr(funcwin," EXIT (hit v to view or setup) "); wmove(funcwin,19,20); waddstr(funcwin,"USE ARROWS TO MOVE CURSOR"); wmove(funcwin,20,18); waddstr(funcwin,"PUSH SPACE TO EXECUTE COMMAND"); wmove(funcwin,8,5); wrefresh(funcwin); } mveup() { wmove(funcwin,row,2); wstandend(funcwin); waddstr(funcwin," "); wrefresh(funcwin); if ( row == topf ) row = botf; else row--; hghlite(); } /************************************************************************** This procedure will move the highlited cursor down one row in the command window. If the cursor is already at the bottom of the command list, calling this procedure will cause the cursor to wrap around to the top of the command list. **************************************************************************/ mvedown() { wmove(funcwin,row,2); wstandend(funcwin); waddstr(funcwin," "); wrefresh(funcwin); if ( row == botf ) row = topf; else row++; hghlite(); } /**************************************************************************** This procedure will highlite the position of the current cursor. ****************************************************************************/ hghlite() { wmove(funcwin,row,2); wstandout(funcwin); waddstr(funcwin,"==>"); wrefresh(funcwin); wmove(funcwin,row,0); wrefresh(funcwin); } /**************************************************************************** end ****************************************************************************/