/* --------------------------------------------------------------------- */ /* - UNIX-TEX 100 PROGRAMMERS INTERFACE - */ /* - VKS101.C - */ /* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */ /* - This file is the programmers interface to the Unix/Ultrix - */ /* - device driver. These are the UNIX-TEX calls. Each call has a - */ /* - series of comments that describes the call, what it does, and - */ /* - what the parameters must be. The Document fg101.doc also - */ /* - describes each call as well. VKS stands for Vision Kernel System */ /* --------------------------------------------------------------------- */ /* - Written by: Roger W. Webster, Ph.D. - */ /* --------------------------------------------------------------------- */ #include #define SUN YES #include #include #include #include #include "/work/users/stuff/alphabet.h" float VIS$EUCLID_DIST(); /* --------------------------------------------------------------------- */ /* - necessary defines for this file: vks101.c - */ /* --------------------------------------------------------------------- */ #define NO 0 #define YES 1 #define TOO_SMALL 6 /* border follow won't find things w/permimeter < this */ #define min(a,b) (a>b ? b : a) #define max(a,b) (a 0) sum_array[count] = sum_array[count] + 1; } Area = Area + sum_array[count]; #ifdef DEBUGROGER if (i == x) { for (c=0; c <= dy; c+=5) { printf ("sum[%3d] %4d", c, values[c]); printf (" sum[%3d] %4d", c+1, values[c+1]); printf (" sum[%3d] %4d", c+2, values[c+2]); printf (" sum[%3d] %4d", c+3, values[c+3]); printf (" sum[%3d] %4d\n", c+4, values[c+4]); } printf (" sum_array[%2d]: %4d \n", count, sum_array[count]); } #endif count++; } return (Area); } /* ------------------------------------------------------------------ */ /* - VIS$HORIZONTAL_SUMS (X, Y, DX, DY, SUM_ARRAY) - */ /* - - */ /* - This routine produces the horizontal projection of pixels in - */ /* - array SUM_ARRAY. The line begins at X, Y and contains - */ /* - DY pixels. DY must be positive.SUM_ARRAY is to be dimensioned - */ /* - to be at least DY integers long. - */ /* - X and Y point to the upper left most position in the box. - */ /* ------------------------------------------------------------------ */ VIS$HORIZONTAL_SUMS ( x,y,dx, dy, sum_array ) int x, y, dx, dy; int *sum_array; { int i,j, count=0, Area=0; int values[641]; for (j = y; j < y+dy; j++) { sum_array[count] = 0; result = rhline( x,j, dx, values); for (i=0; i < dx; i++) if (values[i] > 0) sum_array[count] = sum_array[count] + 1; Area = Area + sum_array[count]; count++; } return (Area); } /* --------------------------------------------------------------------- VIS$SET_VMASK (mask) This routine sets the Video Acquisition Mask for R/W ---------------------------------------------------------------------------*/ VIS$SET_VMASK(mask) int mask; { if (mask == 0) VIS$SET_XSPIN (0x0010); else VIS$SET_XSPIN (0); setvmask(mask); } /* --------------------------------------------------------------------- VIS$GET_VMASK (mask) This routine returns the Video Acquisition Mask for R/W ---------------------------------------------------------------------------*/ VIS$GET_VMASK(mask) int *mask; { *mask = getvmask(); } /* --------------------------------------------------------------------- VIS$VMASK () This routine masks the upper 4 bits of the Video Acquisition Mask ---------------------------------------------------------------------------*/ VIS$VMASK() { setvmask(0xff00); VIS$SET_XSPIN (0); } /* --------------------------------------------------------------------- */ /* - VIS$BLOCK (x1, y1, x2, y2, grey) - */ /* - - */ /* - This routine writes a block of pixels - */ /*-----------------------------------------------------------------------*/ VIS$BLOCK (x1, y1, x2, y2, grey) int x1, y1, x2, y2, grey; { int dx, dy; dx = (x2-x1) + 1; dy = (y2-y1) + 1; aclear (x1, y1, dx, dy, grey); wpixel(x1, y1, grey); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$COPY_BLOCK (x1, y1, x2, y2, x_to, to_y) - */ /* - - */ /* - This routine copies a block of pixels in the Frame Buffer - */ /*-----------------------------------------------------------------------*/ VIS$COPY_BLOCK (x1, y1, x2, y2, to_x, to_y) int x1, y1, x2, y2, to_x, to_y; { int dx, dy; dx = (x2-x1) + 1; dy = (y2-y1) + 1; carea (x1, y1, dx, dy, to_x, to_y, dx, dy); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$COPY_LINE (x1, y1, length, x_to, to_y) - */ /* - - */ /* - This routine copies a line - */ /*-----------------------------------------------------------------------*/ VIS$COPY_LINE (x1, y1, length, to_x, to_y) int x1, y1, length, to_x, to_y; { cline (x1, y1, length, to_x, to_y); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$FRAME_MEMORY (on) - */ /* - - */ /* - This routine sets luts selected or frame memory - */ /* --------------------------------------------------------------------- */ VIS$FRAME_MEMORY (on) int on; { if (on) /* 1 is on 0 is off */ fgon(); else fgoff(); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$GET_FRAME_MEMORY (info) - */ /* - - */ /* - This routine gets luts selected or frame memory - */ /* --------------------------------------------------------------------- */ VIS$GET_FRAME_MEMORY (on) int *on; { *on = FRAME_MEMORY; } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$SELECT_LUT (set,member) - */ /* - - */ /* - This procedure selects the active input and output LUTs. - */ /* - A slight diversion - The value for set ranges from 0..3 - */ /* - while the value for member ranges from 0..15. - */ /* --------------------------------------------------------------------- */ VIS$SELECT_LUT(set,member) int set; /* - Used for i,r,g,b - */ int member; /* - Used for 0..15 - */ { switch (set) { case 0 : setlut(INPUT, member); break; case 1 : setlut(RED, member); break; case 2 : setlut(GREEN, member); break; case 3 : setlut(BLUE, member); break; } /* end case */ } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$GET_LUT (inlut, outlut) - */ /* - - */ /* - This routine returns the value of the luts selected - */ /* --------------------------------------------------------------------- */ VIS$GET_LUT (inlut, outlut) int *inlut, *outlut; { *outlut = 0; *inlut = 0; /* for now RWW */ } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$LOAD_LUT(set, member, vals) - */ /* - - */ /* - This routine SETS and LOADS the lut specified by - */ /* - set and member with the contents of a 256 integer array (vals) - */ /* --------------------------------------------------------------------- */ VIS$LOAD_LUT(set, member, values) int set, member; int *values; { switch (set) { case 0 : walut(INPUT, member, 0, 256, values); setlut(INPUT, member); break; case 1 : walut(RED, member, 0, 256, values); setlut(RED, member); break; case 2 : walut(GREEN, member, 0, 256, values); setlut(GREEN, member); break; case 3 : walut(BLUE, member, 0, 256, values); setlut(BLUE, member); break; } /* end case */ return (1); } /* --------------------------------------------------------------------- */ /* - VIS$LINEARIZE_LUT (set,member) - */ /* - - */ /* - This procedure linearizes a lut - */ /* --------------------------------------------------------------------- */ VIS$LINEARIZE_LUT(set,member) int set; /* - Used for i,r,g,b - */ int member; /* - Used for 0..15 - */ { switch (set) { case 0 : linlut(INPUT, member); setlut(INPUT, member); break; case 1 : linlut(RED, member); setlut(RED, member); break; case 2 : linlut(GREEN, member); setlut(GREEN, member); break; case 3 : linlut(BLUE, member); setlut(BLUE, member); break; } /* end case */ } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$THRESHOLD_LUT (set,member,threshold) - */ /* - - */ /* - This procedure creates a binary thresholded lut - */ /* --------------------------------------------------------------------- */ VIS$THRESHOLD_LUT(set,member, threshold) int set; /* - Used for i,r,g,b - */ int member; /* - Used for 0..15 - */ int threshold; { int i; int values[256]; for(i=0;i<=255;i++) /* THRESHOLD LUT */ values[i] = (i <= threshold) ? 0:255; VIS$LOAD_LUT (set,member, values); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$INVERSE_LUT (set,member) - */ /* - - */ /* - This procedure inverses the lut specified - */ /* --------------------------------------------------------------------- */ VIS$INVERSE_LUT(set, member) int set; /* - Used for i,r,g,b - */ int member; /* - Used for 0..15 - */ { switch (set) { case 0 : invlut(INPUT, member); setlut(INPUT, member); break; case 1 : invlut(RED, member); setlut(RED, member); break; case 2 : invlut(GREEN, member); setlut(GREEN, member); break; case 3 : invlut(BLUE, member); setlut(BLUE, member); break; } /* end case */ } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$DYNAMIC_OUTLUT (on/off) - */ /* - - */ /* - This routine sets the dynamic output lut bit SSEL - */ /* --------------------------------------------------------------------- */ VIS$DYNAMIC_OUTLUT (on) int on; { if (on) /* 1 is on - 0 is off */ { dynamic_luts(); DYNAMIC_LUT = YES; } else { static_luts(); DYNAMIC_LUT = NO; } } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$GET_DYNAMIC_OUTLUT (on) - */ /* - - */ /* - This routine gets the dynamic output lut bit SSEL - */ /* --------------------------------------------------------------------- */ VIS$GET_DYNAMIC_OUTLUT (on) int *on; { *on = DYNAMIC_LUT; } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$SET_VIDEO_CHANNEL (channel) - */ /* - - */ /* - This routine sets the video channel - */ /* --------------------------------------------------------------------- */ VIS$SET_VIDEO_CHANNEL (channel) int channel; { setcamera(channel); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$GET_VIDEO_CHANNEL (channel) - */ /* - - */ /* - This routine gets the video channel - */ /* --------------------------------------------------------------------- */ VIS$GET_VIDEO_CHANNEL (channel) int *channel; { *channel = getcamera(); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$SUBTRACT_OUTLUT(threshold) - */ /* - - */ /* - This loads the output lut for real time subtraction (mode 6) - */ /* --------------------------------------------------------------------- */ VIS$SUBTRACT_OUTLUT(threshold) int threshold; { int i; int values[256]; for(i=0;i<256;i++) values[i] = (i & 0x003f) * 4; /* and it with 003f hex in */ VIS$LOAD_LUT (1,9, values); VIS$LOAD_LUT (2,9, values); VIS$LOAD_LUT (3,9, values); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$WEDGE() - */ /* - - */ /* - This procedure draws a test wedge on the screen - */ /* --------------------------------------------------------------------- */ VIS$WEDGE() { wedge(); } /* --------------------------------------------------------------------- */ /* - VIS$GRID (increment, grey) - */ /* - - */ /* - This procedure draws a fine test grid on the screen - */ /* --------------------------------------------------------------------- */ VIS$GRID(incr, grey) int incr, grey; { grid (incr, incr, grey); } /* --------------------------------------------------------------------- */ /* - VIS$DRAWLINE (x1,y1, x2,y2, grey) - */ /* - - */ /* - This procedure draws a line with the parms above - */ /* --------------------------------------------------------------------- */ VIS$DRAWLINE (pt1x,pt1y,pt2x,pt2y,color) int pt1x,pt1y,pt2x,pt2y,color; { int x,y,deltax,deltay; float b,k, slope; float m,n; int i,l,p, vert; vert = 0; l = (pt2x - pt1x); p = (pt2y - pt1y); if (l == 0) { vert = 1; slope = 0; } else slope = (float)p / (float)l;; if ((pt2x - pt1x) < 0) deltax = -1 * (pt2x - pt1x); else deltax = pt2x - pt1x; b = pt1y - (slope * pt1x); if ((pt2y - pt1y) < 0) deltay = -1 * (pt2y - pt1y); else deltay = (pt2y - pt1y); if ((slope >= 1) || (slope <= -1) || (vert)) for (i = 0; i <= deltay; i++) if (pt1y - pt2y >= 0) { if (deltax == 0) x = pt1x; else x = (int)(((pt1y - i) - b)/ slope); /* WAS ROUND HERE */ wpixel(x,pt1y-i,color); } else { if (deltax == 0) x = pt1x; else x = (int)(((pt1y + i) - b) / slope); wpixel(x,pt1y+i,color); } else for (i = 0; i <= deltax; i++) if (pt1x - pt2x >= 0) { l = pt1x - i; m = slope * l; k = m + b ; y = (int)(k); wpixel(pt1x-i,y,color); } else { l = pt1x + i; m = slope * l; k = m + b; y = (int)(k); wpixel(pt1x+i,y,color); } } /* end drawline */ /* --------------------------------------------------------------------- */ /* - VIS$GET_LINE (x1,y1, x2,y2, grey, linex, liney) - */ /* - - */ /* - This procedure gets a line - */ /* --------------------------------------------------------------------- */ VIS$GET_LINE (pt1x,pt1y,pt2x,pt2y, color, linex, liney) int pt1x,pt1y,pt2x,pt2y,color, *linex, *liney; { int grey; int x,y,deltax,deltay; float b,k, slope; float m,n; int i,l,p, vert; vert = 0; l = (pt2x - pt1x); p = (pt2y - pt1y); if (l == 0) { vert = 1; slope = 0; } else slope = (float)p / (float)l;; if ((pt2x - pt1x) < 0) deltax = -1 * (pt2x - pt1x); else deltax = pt2x - pt1x; b = pt1y - (slope * pt1x); if ((pt2y - pt1y) < 0) deltay = -1 * (pt2y - pt1y); else deltay = (pt2y - pt1y); if ((slope >= 1) || (slope <= -1) || (vert)) for (i = 0; i <= deltay; i++) if (pt1y - pt2y >= 0) { if (deltax == 0) x = pt1x; else x = round(((pt1y - i) - b)/ slope); grey = rpixel(x,pt1y-i); if (grey == color) { *linex = x; *liney = pt1y-i; return(1); /* stop the whole show */ } } else { if (deltax == 0) x = pt1x; else x = round(((pt1y + i) - b) / slope); grey = rpixel(x,pt1y+i); if (grey == color) { *linex = x; *liney = pt1y+i; return(1); /* stop the whole show */ } } else for (i = 0; i <= deltax; i++) if (pt1x - pt2x >= 0) { l = pt1x - i; m = slope * l; k = m + b ; y = round(k); grey = rpixel(pt1x-i,y); if (grey == color) { *linex = pt1x-i; *liney = y; return(1); /* stop the whole show */ } } else { l = pt1x + i; m = slope * l; k = m + b; y = round(k); grey = rpixel(pt1x+i,y); if (grey == color) { *linex = pt1x+i; *liney = y; return(1); /* stop the whole show */ } } return(0); /* didn't find elevation */ } /* end getline */ /* --------------------------------------------------------------------- */ /* - VIS$GET_PERP_LINE (x1,y1, x2,y2, color_get, color_set, color_stop,- */ /* linex, liney) - */ /* - - */ /* - This procedure gets a perpendicular line - */ /* --------------------------------------------------------------------- */ VIS$GET_PERP_LINE(pt1x,pt1y,pt2x,pt2y,color_get, color_set, color_stop, linex, liney) int pt1x,pt1y,pt2x,pt2y,color_get, color_set, color_stop, *linex, *liney; { int grey; int x,y,deltax,deltay; float b,k, slope; float m,n; int i,l,p, vert; int len = 0; /* returns the length of the line, i.e., number of points */ vert = 0; l = (pt2x - pt1x); p = (pt2y - pt1y); if (l == 0) { vert = 1; slope = 0; } else slope = (float)p / (float)l;; if ((pt2x - pt1x) < 0) deltax = -1 * (pt2x - pt1x); else deltax = pt2x - pt1x; b = pt1y - (slope * pt1x); if ((pt2y - pt1y) < 0) deltay = -1 * (pt2y - pt1y); else deltay = (pt2y - pt1y); if ((slope >= 1) || (slope <= -1) || (vert)) for (i = 0; i <= deltay; i++) if (pt1y - pt2y >= 0) { if (deltax == 0) x = pt1x; else x = round(((pt1y - i) - b)/ slope); grey = rpixel(x,pt1y-i); if (grey == color_get) { *linex = x; *liney = pt1y-i; len++; } if (grey == color_stop) return(0); /* stop the whole show */ wpixel(x,pt1y-i,color_set); } else { if (deltax == 0) x = pt1x; else x = round(((pt1y + i) - b) / slope); grey = rpixel(x,pt1y+i); if (grey == color_get) { *linex = x; *liney = pt1y+i; len++; } if (grey == color_stop) return(0); /* stop the whole show */ wpixel(x,pt1y+i,color_set); } else for (i = 0; i <= deltax; i++) if (pt1x - pt2x >= 0) { l = pt1x - i; m = slope * l; k = m + b ; y = round(k); grey = rpixel(pt1x-i,y); if (grey == color_get) { *linex = pt1x-i; *liney = y; len++; } if (grey == color_stop) return(0); /* stop the whole show */ wpixel(pt1x-i,y,color_set); } else { l = pt1x + i; m = slope * l; k = m + b; y = round(k); grey = rpixel(pt1x+i,y); if (grey == color_get) { *linex = pt1x+i; *liney = y; len++; } if (grey == color_stop) return(0); /* stop the whole show */ wpixel(pt1x+i,y,color_set); } } /* end getperpline */ /* --------------------------------------------------------------------- */ /* - VIS$SET_X (x) - */ /* - - */ /* - This routine sets the X register - */ /* --------------------------------------------------------------------- */ VIS$SET_X (x) int x; { setreg(0x8, x); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$SET_Y (y) - */ /* - - */ /* - This routine sets the Y register - */ /* --------------------------------------------------------------------- */ VIS$SET_Y (y) int y; { setreg(0xA, y); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$PAGE (page) - */ /* - - */ /* - This procedure sets pan & scroll to the page # ex. 1,2,3,4 - */ /* --------------------------------------------------------------------- */ VIS$PAGE (page) int page; { int pan, scroll; switch (page) { case 1 : pan = 0; scroll = 0; break; case 2 : pan = 383; scroll = 0; break; case 3 : pan = 0; scroll = 512; break; case 4 : pan = 383; scroll = 512; break; default: pan = 0; scroll = 0; break; } /* end case */ VIS$ROAM(pan, scroll); } /* end function */ /*****************************************************************************/ /* VIS$SAVE_PICTURE (x1,y1, x2,y2, filename) */ /* */ /* This function saves any rectangular portion of the screen into a disk */ /* file. */ /*****************************************************************************/ VIS$SAVE_PICTURE ( x1, y1, x2, y2, filename ) int x1, y1, x2, y2; char *filename; { int dx, dy; int format = 0; /* format is 8 bit images */ char *comment = "robot vison and AI lab"; dx = (x2-x1)+1; dy = (y2-y1)+1; saveim (x1,y1, dx,dy, format, filename, comment); } /* end of save_picture */ /****************************************************************************/ /* VIS$READ_PICTURE (x,y,filename) */ /* */ /* This function reads an image stored in a disk file and places it at the */ /* indicated position on the moniter. */ /****************************************************************************/ VIS$READ_PICTURE (x, y, filename ) int x, y; char filename[]; { int dx=640, dy=480; readim (x,y, dx,dy, filename); } /* end of read_picture */ /* --------------------------------------------------------------------- */ /* - VIS$OUT_THRESH_LUT (member,threshold) - */ /* - - */ /* - This procedure creates a binary thresholded lut (OUTPUT LUT) - */ /* --------------------------------------------------------------------- */ VIS$OUT_THRESH_LUT(member, threshold) int member; /* - Used for 0..15 - */ int threshold; { int i; int values[256]; for(i=0;i<=255;i++) /* THRESHOLD LUT */ values[i] = (i <= threshold) ? 0:255; VIS$LOAD_LUT( 2, member, values ); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$SETUP_OUT_THRESH (member) - */ /* - - */ /* - This procedure creates a binary thresholded lut (OUTPUT LUT) - */ /* --------------------------------------------------------------------- */ VIS$SETUP_OUT_THRESH (member) int member; /* - Used for 0..15 - */ { int i; int values[256]; for(i=0;i<=255;i++) /* THRESHOLD LUT */ values[i] = 0; VIS$LOAD_LUT( 1, member, values ); VIS$LOAD_LUT( 2, member, values ); VIS$LOAD_LUT( 3, member, values ); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$BORDER_FOLLOW( length,x,y,targrey,newgrey,startx,starty, - */ /* - endx,endy,increments ) - */ /* - - */ /* - The purpose of this function is to locate an object of - */ /* - greyshade TARGREY within a range specified by STARTX,STARTY to - */ /* - ENDX,ENDY. The routine will search by horizontally scanning - */ /* - every row which is a multiple of INCREMENTS. When the target - */ /* - greyshade is found, this routine will outline the object by - */ /* - changing the greyshade to NEWGREY. When the function is done - */ /* - an array of X,Y coordinates are returned along with the computed- */ /* - LENGTH of the objects perimeter. - */ /* - - */ /* - returns 1 if it found the object, 0 if it did not - */ /* --------------------------------------------------------------------- */ VIS$BORDER_FOLLOW(length,x,y,targrey,newgrey,startx,starty,endx,endy,increments) int *length,*x,*y,targrey,newgrey,startx, starty, endx, endy, increments; { int i=0,found = 0, dx; int values[640]; dx = (endx - startx) + 1; while((starty <= endy) && (!found)) { rhline(startx, starty, dx, values); while((values[i] != targrey) && (i < dx)) i++; if (i != dx) { if (VIS$TRACE_CONTOUR(i + startx,starty,length,x,y,targrey,newgrey)) found = 1; else { starty += increments; i = 0; } } else { starty += increments; i = 0; } } return (found); } /* --------------------------------------------------------------------- */ /* - VIS$BORDER_FOLLOW_UP( length,x,y,targrey,newgrey,startx,starty, - */ /* - endx,endy,increments ) - */ /* - - */ /* - The purpose of this function is to locate an object of - */ /* - greyshade TARGREY within a range specified by STARTX,STARTY to - */ /* - ENDX,ENDY. The routine will search by horizontally scanning - */ /* - every row which is a multiple of INCREMENTS. When the target - */ /* - greyshade is found, this routine will outline the object by - */ /* - changing the greyshade to NEWGREY. When the function is done - */ /* - an array of X,Y coordinates are returned along with the computed- */ /* - LENGTH of the objects perimeter. - */ /* - - */ /* - returns 1 if it found the object, 0 if it did not - */ /* - Remember this UP functions scans from the bottom UP (endy UP) - */ /* --------------------------------------------------------------------- */ VIS$BORDER_FOLLOW_UP(length,x,y,targrey,newgrey,startx,starty,endx,endy,increments) int *length,*x,*y,targrey,newgrey,startx, starty, endx, endy, increments; { int i=0,found = 0, dx; int values[640]; dx = (endx - startx) + 1; while((endy > starty) && (!found)) { rhline(startx, endy, dx, values); while((values[i] != targrey) && (i < dx)) i++; if (i != dx) { if (VIS$TRACE_CONTOUR(i + startx,endy,length,x,y,targrey,newgrey)) found = 1; else { endy -= increments; i = 0; } } else { endy -= increments; i = 0; } } return (found); } /*-----------------------------------------------------------------------*/ /* G E T - X Y */ /* This routine returns the x,y, coordinates given the direction 0..7 */ /*-----------------------------------------------------------------------*/ VIS$GET_XY (s, x, y, lookx, looky) int s, x, y, *lookx, *looky; { switch (s) { case 0 : *lookx = x + 1; *looky = y; break; case 1 : *lookx = x + 1; *looky = y - 1; break; case 2 : *lookx = x; *looky = y - 1; break; case 3 : *lookx = x - 1; *looky = y - 1; break; case 4 : *lookx = x - 1; *looky = y; break; case 5 : *lookx = x - 1; *looky = y + 1; break; case 6 : *lookx = x; *looky = y + 1; break; case 7 : *lookx = x + 1; *looky = y + 1; break; default : break; } /* end case */ } /* end function get_xy */ /*-----------------------------------------------------------------------*/ /* T R A C E - C O N T O U R */ /* */ /* returns 1 if it traced it 0 if it did not */ /*-----------------------------------------------------------------------*/ VIS$TRACE_CONTOUR (x1,y1,length,x,y,targrey,newgrey) int x1,y1,*length,*x,*y,targrey,newgrey; { struct points { int x, y; }; struct points a,c ; int first88 = 1; /* should be 1 */ int found = 0; int traced = 0; /* assume NOT traced yet */ int s=6; /* direction of search*/ /* as per Pavlidis pg. 143 Algor for G & ImageP*/ /* 3 2 1 4 P 0 5 6 7 Directions */ int sub; int lookx, looky, times, grey, z; sub = 1; x[1] = x1; y[1] = y1; sub++; c.x = x1; c.y = y1; a.x = x1; a.y = y1; wpixel(0, 0, 0); wpixel(x[1], y[1], newgrey /* 99 */); do { found = 0; times = 0; first88 = 1; do { times++; if (s == 0) VIS$GET_XY (7, c.x, c.y, &lookx, &looky); else VIS$GET_XY (s-1, c.x, c.y, &lookx, &looky); grey = rpixel(lookx, looky); if (grey == targrey || grey == newgrey) { c.x = lookx; c.y = looky; x[sub] = lookx; y[sub] = looky; sub++; if (s == 0) s = 6; else if (s == 1) s = 7; else s = s - 2; found = 1; /*if (grey == newgrey) wpixel(lookx, looky, newgrey -1); else */ wpixel(lookx, looky, newgrey); } if (!found) { VIS$GET_XY (s, c.x, c.y, &lookx, &looky); grey = rpixel(lookx, looky); if (grey == targrey || grey == newgrey) { c.x = lookx; c.y = looky; x[sub] = lookx; y[sub] = looky; sub++; found = 1; /*if (grey == newgrey) wpixel(lookx, looky, newgrey -1); else */ wpixel(lookx, looky, newgrey); } } if (!found) { VIS$GET_XY ((s + 1) % 8, c.x, c.y, &lookx, &looky); grey = rpixel(lookx, looky); if (grey == targrey || grey == newgrey) { c.x = lookx; c.y = looky; x[sub] = lookx; y[sub] = looky; sub++; found = 1; /*if (grey == newgrey) wpixel(lookx, looky, newgrey -1); else */ wpixel(lookx, looky, newgrey); } } if (!found) { s = (s +2) % 8; if (times == 3) { return (traced); /* traced = 0 not traced */ } /* endif times ==3 */ } /* end if not found */ } while (!found); } while (!ISCLOSE(c.x,a.x) || !ISCLOSE(c.y, a.y) || sub < 4); *length = sub - 1; if (*length < TOO_SMALL) /* too short random noise or one point islands */ { printf("perimeter TOO SMALL to process \n"); for (z=1;z<=*length;z++) wpixel(x[z], y[z], targrey); traced = NO; } else traced = YES; return (traced); } /* end tracer function */ /* --------------------------------------------------------------------- */ /* - VIS$GET_MAX_XY (x, y, length, minx, miny, maxx, maxy) - */ /* - - */ /* - - */ /* - this routine gets the minx miny maxx maxy of the object for AOI - */ /* --------------------------------------------------------------------- */ VIS$GET_MAX_XY (x, y, length, minx, miny, maxx, maxy) int *x, *y, length, *minx, *miny, *maxx, *maxy; { int i; *minx = *miny = 512; *maxx = *maxy = 0; for (i=1; i<=length; i++) { if (x[i] > *maxx) *maxx = x[i]; if (x[i] < *minx) *minx = x[i]; /* */ if (y[i] > *maxy) *maxy = y[i]; if (y[i] < *miny) *miny = y[i]; } } /* --------------------------------------------------------------- */ /* - VIS$FILL_AREA( x, y, col ) - */ /* - This routine is a recursive fill algorithm. It requires - */ /* - that col be the same value as the border. This routine - */ /* - only works for regions with small area. - */ /* --------------------------------------------------------------- */ VIS$FILL_AREA( x, y, col ) int x,y,col; { int i; wpixel( x, y, col ); if (rpixel( x+1, y ) != col ) VIS$FILL_AREA( x+1, y, col ); if (rpixel( x, y-1 ) != col ) VIS$FILL_AREA( x, y-1, col ); if (rpixel( x-1, y ) != col ) VIS$FILL_AREA( x-1, y, col ); if (rpixel( x, y+1 ) != col ) VIS$FILL_AREA( x, y+1, col ); } /* ---------------------------------------------------------------- */ /* - VIS$CIRCLE( xc, yc, r, grey ) - */ /* - This routine calls VIS$ELLIPSE passing the center xc,yc - */ /* - and makes the ellipse's major and minor axis r. 'grey' - */ /* - is a value between 0 - 255. - */ /* - NOTE: This only works for square pixel boards. - */ /* ---------------------------------------------------------------- */ VIS$CIRCLE( xc, yc, r, col ) int xc, yc, r, col; { VIS$ELLIPSE( xc, yc, r, r, col ); } /* ---------------------------------------------------------------- */ /* - VIS$ELLIPSE( xc, yc, a, b, grey ) - */ /* - This routine is based on Breshinheim's algoritm for fast - */ /* - ellipses. The algorithm calculates one quarter of the - */ /* - ellipse and mirrors the other 3 sides accordingly. - */ /* ---------------------------------------------------------------- */ VIS$ELLIPSE( xc,yc,a,b,col ) int xc, yc, a, b, col; { float c1,c2,c3,c4,c5,p,x,y; /* Set up constants for calculations in loop */ x=0; y=b; p=(a*a)*(1-(2*b))+(2*((b*b))); c1=(a*a)*4; c2=(b*b)*4; c3=(b*b)*6; c4=c1+c3; c5=((float)a*(float)a)/((float)b*(float)b); /* Start from (0,b) and proceed until the tangent has slope -1 */ while ( (c5*y) > x ) { setpix( xc, yc, (int)x, (int)y, col ); if ( p < 0 ) p = p+(c2*x)+c3; else { p=p+(c2*x)-(c1*y)+c4; y=y-1.0; } x=x+1.0; } /* Set up constants for calculations in loop */ y=0; x=a; p=(b*b)*(1-(2*a))+(2*(a*a)); c1=(b*b)*4; c2=(a*a)*4; c3=(a*a)*6; c4=c1+c3; c5=((float)b*(float)b)/((float)a*(float)a); /* Start from (a,0) and proceed until the tangent has slope -1 */ while ( (c5*x) > y-1.0 ) { setpix( xc, yc, (int)x, (int)y, col ); if ( p < 0 ) p = p+(c2*y)+c3; else { p=p+(c2*y)-(c1*x)+c4; x=x-1.0; } y=y+1.0; } } setpix( xc,yc,x,y,col ) int xc,yc,x,y,col; { /* Plot the four coresponding points on the ellipse */ wpixel(( xc + x),( yc - y), col ); /* quad 1 */ wpixel(( xc - x),( yc - y), col ); /* quad 2 */ wpixel(( xc - x),( yc + y), col ); /* quad 3 */ wpixel(( xc + x),( yc + y), col ); /* quad 4 */ } /* ---------------------------------------------------------------- */ /* - VIS$FILL_CIRCLE( xc, yc, r, grey ) - */ /* - This routine calls VIS$FILL_ELLIPSE passing the xc,yc - */ /* - and makes the ellipse's major and minor axis r. 'grey' - */ /* - is a value between 0 - 255. - */ /* - NOTE: This only works for square pixel boards. - */ /* ---------------------------------------------------------------- */ VIS$FILL_CIRCLE( xc, yc, r, col ) int xc, yc, r, col; { VIS$FILL_ELLIPSE( xc, yc, r, r, col ); } /* ---------------------------------------------------------------- */ /* - VIS$FILL_ELLIPSE( xc, yc, a, b, grey ) - */ /* - This routine is based on Breshinheim's algoritm for fast - */ /* - ellipses. The algorithm calculates one quarter of the - */ /* - ellipse and mirrors the other 3 sides accordingly. - */ /* ---------------------------------------------------------------- */ VIS$FILL_ELLIPSE( xc,yc,a,b,col ) int xc, yc, a, b, col; { float c1,c2,c3,c4,c5,p,x,y; int i, *brett_vals; if ((brett_vals = (int *)malloc(2*a*sizeof(int)+5)) == NULL) return(-1); for (i=0; i < 2*a+5; i++ ) brett_vals[i] = col; /* Set up constants for calculations in loop */ x=0; y=b; p=(a*a)*(1-(2*b))+(2*((b*b))); c1=(a*a)*4; c2=(b*b)*4; c3=(b*b)*6; c4=c1+c3; c5=((float)a*(float)a)/((float)b*(float)b); /* Start from (0,b) and proceed until the tangent has slope -1 */ while ( (c5*y) > x ) { whline((xc-(int)x),(yc-(int)y),(2*(int)x+1),brett_vals); whline((xc-(int)x),(yc+(int)y),(2*(int)x+1),brett_vals); if ( p < 0 ) p = p+(c2*x)+c3; else { p=p+(c2*x)-(c1*y)+c4; y=y-1.0; } x=x+1.0; } /* Set up constants for calculations in loop */ y=0; x=a; p=(b*b)*(1-(2*a))+(2*(a*a)); c1=(b*b)*4; c2=(a*a)*4; c3=(a*a)*6; c4=c1+c3; c5=((float)b*(float)b)/((float)a*(float)a); /* Start from (a,0) and proceed until the tangent has slope -1 */ while ( (c5*x) > y-1.0 ) { whline((xc-(int)x),(yc-(int)y),(2*(int)x+1),brett_vals); whline((xc-(int)x),(yc+(int)y),(2*(int)x+1),brett_vals); if ( p < 0 ) p = p+(c2*y)+c3; else { p=p+(c2*y)-(c1*x)+c4; x=x-1.0; } y=y+1.0; } free(brett_vals); } /************************************************************************** EUCLID_DISTANCE ***************************************************************************/ float VIS$EUCLID_DIST(x1,y1,x2,y2) int x1,y1,x2,y2; { float a, b; a = (float)(x2 - x1); b = (float)(y2 - y1); a = a*a; b = b*b; return ( (float)sqrt((double)(a+b)) ); } /************************************************************************** CHESSBOARD_DISTANCE ***************************************************************************/ VIS$CHESSBOARD_DIST(x1,y1,x2,y2) int x1,y1,x2,y2; { return ( max( abs(x1-x2), abs (y2-y1)) ); } /************************************************************************** CITY_BLOCK_DISTANCE ***************************************************************************/ VIS$CITY_BLOCK_DIST(x1,y1, x2,y2) int x1,y1, x2,y2; { int x; x = abs(x2-x1) + abs(y2-y1); return ( x ); } /************************************************************************** D I S T A N C E ***************************************************************************/ VIS$DISTANCE(x1,y1,x2,y2) int x1,y1,x2,y2; { float a,b; float q; double c; a = (float)(x2 - x1); b = (float)(y2 - y1); a = a*a; b = b*b; return ( (int)(a+b) ); } /**************************************************************************** R O U N D ****************************************************************************/ round(f) float f; { return((f - (int)f >= 0.5) ? (int)f + 1: (int)f); } /* ---------------------------------------------------------------- */ /* - VIS$HISTOGRAM ( x1, y1, x2, y2, equalize) - */ /* - This routine performs a histogram. if equalize = 1 then - */ /* - it will perform a histogram equalization with the luts. - */ /* - PROGRAMMER: Michael A. Henry - */ /* - SAMPLE CALL: Histogram(x1,y1, x2,y2, 1); - */ /* ---------------------------------------------------------------- */ VIS$HISTOGRAM(x1,y1,x2,y2,equalize) int x1,y1,x2,y2, equalize; { int i,x, eos; int offset,base,largest,grpfact,barwidth,area,X1,X2; int values[641]; int harray[255]; /* Histogram array, read from fb */ int darray[255]; /* Display array, bars displayed on screen */ float scale; VIS$FREEZE(); /* CONSTANTS */ grpfact=4; barwidth=8; base=470; area=(y2-y1)*(x2-x1); eos=256/grpfact-1; /* End Of Scale */ /* BOX AOI */ VIS$DRAW_BOX(x1,y1,x2,y2,0,10); /* INITIALIZE ARRAYS */ for (i=0;i<=255;i++) { harray[i] = 0; darray[i] = 0; } /* FILL HARRAY WITH READ_HORIZONTAL_LINE */ for (i=y1;i<=y2;i++) { rhline(x1,i,x2-x1,values); for (x=0;x largest) largest = darray[i]; scale = 1.0/((float)largest/((float)base-25.0)); printf ("largest -> %d\n", largest); /* DISPLAY HISTOGRAM FUNCTION OVER IMAGE */ X1=0; X2=barwidth; VIS$DRAW_BOX(0,25,barwidth*(256/grpfact+1),base,0,0); for (i=0;i<=eos;i++) { X1+=barwidth; X2+=barwidth; VIS$BLOCK(X1,(int)(base-(darray[i]*scale)), X2, base, 0); } } /* end if not equalize */ if (equalize) equalize_histogram(harray,area); } /* end function */ float pos(x) float x; { if (x<0) x*=(-1.0); return(x); } equalize_histogram(harray,area) int harray[255]; int area; { int values[256]; float t[255],sum[255],increment,tolerance; int i,x ; int earray[255]; /* for histogram */ /* INITIALIZE ARRAYS */ for (i=0;i<255;i++) { t[i]=0.0; sum[i]=0.0; earray[i]=0; } /* TRANSFORM HARRAY INTO T */ for (i=0;i<255;i++) t[i] = (float)harray[i]/(float)area; /* SUMMATION OF T */ for (i=0;i<255;i++) { if (i==0) sum[i] = t[0]; else sum[i] = sum[i-1] + t[i]; } /* MAP SUM INTO EARRAY USING 1/255 */ x=0; increment = 1.0/255.0; tolerance = 1.0/64.0; for (i=0;i<255;i++) while (pos(sum[x]-(i*increment)) < tolerance) { earray[x]=i; x+=1; } /* SET IN LUT */ for (i=0;i<255;i++) values[i]=earray[i]; VIS$LOAD_LUT (0, 14, values); VIS$SET_MODE(1); VIS$FREEZE(); VIS$SET_MODE(0); } /* --------------------------------------------------------------------- */ /* - VIS$GET_COLOR_IMAGE - */ /* - - */ /* - This routine will grab a single color image assuming the luts - */ /* - have been set using VIS$SET_TRUE_LUTS(). Calling this routine - */ /* - within a loop will simulate real-time color viewing. - */ /* --------------------------------------------------------------------- */ VIS$GET_COLOR_IMAGE() { VIS$SET_VIDEO_CHANNEL (0); VIS$SELECT_LUT(0,0); VIS$SET_VMASK(0xff0); VIS$GRAB(1); VIS$SET_VIDEO_CHANNEL (1); VIS$SELECT_LUT(0,1); VIS$SET_VMASK(0xf0f); VIS$GRAB(1); VIS$SET_VIDEO_CHANNEL (2); VIS$SELECT_LUT(0,2); VIS$SET_VMASK(0x0ff); VIS$GRAB(1); VIS$SET_VMASK(0x0); } /* --------------------------------------------------------------------- */ /* - VIS$SET_TRUE_LUTS - */ /* - - */ /* - This routine sets the I/O luts for single board color imaging. - */ /* - True color is based on four (4) bits per color. - */ /* - - */ /* - NOTE: This routine sets the Dynamic Lut Select bit and therefore - */ /* - the routines using Dynamic Lut Select can not be used while - */ /* - proccessing color. - */ /* --------------------------------------------------------------------- */ VIS$SET_TRUE_LUTS() { int x,i; int values[256]; for ( i=0; i<256; i++) values[i] = (i/16); VIS$LOAD_LUT(0,0, values); for ( i=0; i<256; i++) values[i] = (i/16) << 4; VIS$LOAD_LUT(0,1, values); for ( i=0; i<256; i++) values[i] = (i/16) << 8; VIS$LOAD_LUT(0,2, values); for(x=0;x<16;x++) { for(i=0;i<256;i++) values[i] = ( (i% 16) * 17) % 256; VIS$LOAD_LUT(1,x, values); } for(x=0;x<16;x++) { for(i=0;i<256;i++) values[i] = ( (i / 16) % 16) * 17; VIS$LOAD_LUT(2,x, values); } for(x=0;x<16;x++) { for(i=0;i<256;i++) values[i] = (x % 16) * 17; VIS$LOAD_LUT(3,x, values); } VIS$DYNAMIC_OUTLUT(1); } /* --------------------------------------------------------------------- VIS$GET_REG (letter, contents) This routine gets the contents of a register ---------------------------------------------------------------------------*/ VIS$GET_REG (letter, contents) char letter; int *contents; { *contents = 0; } /* end function */ /* --------------------------------------------------------------------- VIS$SET_REG (letter, contents) This routine sets the contents of a register ---------------------------------------------------------------------------*/ VIS$SET_REG (letter, contents) char letter; int contents; { } /* end function */ /* --------------------------------------------------------------------- VIS$AND_REG (letter, mask) This routine ANDs the contents of a register ---------------------------------------------------------------------------*/ VIS$AND_REG (letter, mask) char letter; int mask; { } /* end function */ /* --------------------------------------------------------------------- VIS$OR_REG (letter, mask) This routine ORs the contents of a register ---------------------------------------------------------------------------*/ VIS$OR_REG (letter, mask) char letter; int mask; { } /* end function */ /* --------------------------------------------------------------------- VIS$SET_XSPIN (hex_amount) This routine sets the X SPIN register ---------------------------------------------------------------------------*/ VIS$SET_XSPIN (hex_amount) int hex_amount; { setreg(0x10, hex_amount); } /* end function */ /* --------------------------------------------------------------------- VIS$GET_XSPIN (hex_amount) This routine gets the X SPIN register ---------------------------------------------------------------------------*/ VIS$GET_XSPIN (hex_amount) int *hex_amount; { *hex_amount = getreg(0x10); } /* end function */ /* --------------------------------------------------------------------- VIS$SET_YSPIN (hex_amount) This routine sets the Y SPIN register ---------------------------------------------------------------------------*/ VIS$SET_YSPIN (hex_amount) int hex_amount; { setreg(12, hex_amount); } /* end function */ /* --------------------------------------------------------------------- VIS$GET_YSPIN (hex_amount) This routine gets the Y SPIN register ---------------------------------------------------------------------------*/ VIS$GET_YSPIN (hex_amount) int *hex_amount; { *hex_amount = getreg(12); } /* end function */ /* ---------------------------------------------------------------- */ /* - VIS$CS455_HISTOGRAM ( x1, y1, x2, y2, equalize, h_array,color)- */ /* - This routine performs a histogram. if equalize = 1 then - */ /* - it will perform a histogram equalization with the luts. - */ /* - SAMPLE CALL: Histogram(x1,y1, x2,y2, 1, Grey_array); - */ /* ---------------------------------------------------------------- */ VIS$CS455_HISTOGRAM(x1,y1,x2,y2,equalize,harray, color) int x1,y1,x2,y2, equalize, *harray, color; { int i,x; int offset,base,largest,grpfact,barwidth,area,X1,X2; int values[641]; float scale,eos; /* CONSTANTS */ grpfact=4; barwidth=8; base= 455 /* was 475 RWW */ ; area=(y2-y1)*(x2-x1); eos=256/grpfact-1; /* End Of Scale */ VIS$DRAW_BOX(x1,y1,x2,y2,color,10); /* INITIALIZE ARRAYS */ for (i=0;i<=255;i++) { harray[i] = 0; } /* FILL HARRAY WITH READ_HORIZONTAL_LINE this is the histogram */ for (i=y1;i<=y2;i++) { rhline(x1,i,x2-x1,values); for (x=0;x largest) largest = original[i]; scale = 1.0/((float)largest/((float)base-25.0)); for (i=0;i <= 254;i++) temp[i] = temp[i] * scale; for (i=0;i <= 254;i++) { VIS$DRAWLINE (i*2, base, i*2, base - temp[i], 135); VIS$DRAWLINE (i*2, base - temp[i], i*2+1, base - temp[i+1], 5); } for (i=0;i <= 254;i++) original[i] = original[i] * scale; for (i=0;i <= 254;i++) { /* VIS$DRAWLINE (i*2, base, i*2, base - original[i], 255); */ VIS$DRAWLINE (i*2, base - original[i], i*2+1, base - original[i+1], 5); } for (i=0; i <= 255;i++) /* was 246 RWW */ { y[i] = temp[i]; } } /* end function */ /*****************************************************************************/ int VIS$OPTIMAL_THRESHOLD(minx,miny,maxx,maxy,histo,color, smooth_factor) /*****************************************************************************/ int minx,miny,maxx,maxy,histo,color,smooth_factor; /* returns the threshold */ { int done = NO; int value[256]; /* array used to hold the grey shades of the digitizer */ int i, j, sum; /* All purpose variables */ int base = 455; /* must be the same as in CS455-histogram stuff */ int width = 4; int how_many = 5; int temp[256]; /* TEMP array used to hold the grey shades */ how_many = smooth_factor; VIS$CS455_HISTOGRAM(minx,miny,maxx,maxy,histo,value,color); VIS$Smooth_Function(value, how_many); done = NO; for (i=how_many;i < (255 - how_many);i++) /* was 246 RWW */ { sum = 0; for (j=i-how_many;j <= i+how_many; j++) { sum += value[j]; } /* end for j */ temp[i] = sum / (how_many * 2 + 1); } /* end for i */ for (i=0;i <= 255;i++) { /*printf ("@ %d was: %d is now %d\n",i,value[i], temp[i]); */ value[i] = temp[i]; } i = how_many+1; while ((done != YES) && (i < 255)) { while ( (value[i-1] <= value[i]) && (value[i] <= value[i+1]) ) i++; i++; /* shawn, what about this ?? !!! */ while ((value[i-1] >= value[i]) && (value[i] >= value[i+1])) i++; done = YES; } VIS$BLOCK (i*2 - width,300,i*2 + width,base,color); return(i); /* return the threshold */ } /* --------------------------------------------------------------------- */ /* - VIS$GRAB(operation) - */ /* - - */ /* - This procedure sets the video acquisition mode of the board: - */ /* - operation < 0 ==> Continuously acquire new images (view) - */ /* - operation = 0 ==> Stop acquisition of images - */ /* - operation > 0 ==> Grab and keep image (freeze) - */ /* --------------------------------------------------------------------- */ VIS$GRAB(operation) int operation; { if (operation < 0) grab(0); if (operation > 0) snap(1); if (operation = 0) stopgrab(1); } /**************************************************************************** E N D P R O G R A M ****************************************************************************/ #ifdef ROGER /* THESE ROUTINES EITHER NOT IMPLEMENTED AS YET OR NO LONGER NECESSARY */ /* --------------------------------------------------------------------- */ /* - VIS$SCAN (xlimit, ylimit, dx, threshold, copy_y, offset, foundx, */ /* - timeout); - */ /* --------------------------------------------------------------------- */ VIS$SCAN (xlimit, ylimit, dx, threshold, copy_y, offset, foundx, timeout) int xlimit, ylimit, dx, threshold, copy_y, offset; int *foundx, timeout; { *foundx = 0; } /* --------------------------------------------------------------------- */ /* - VIS$MAP() - */ /* - - */ /* - This procedure opens the device and returns YES - */ /* --------------------------------------------------------------------- */ VIS$MAP() { /* stuff needed for the SUN 330 platform */ unsigned base = 0x1000; long mem = 0xa00000L; int flag = 1, block = 1; sethdw(base, mem, flag, block); return(YES); } /* --------------------------------------------------------------------- */ /* - VIS$READ_CURRENT_LOCATION(x,y) - */ /* - - */ /* - This routine will return the most recently addressed pixel. - */ /* --------------------------------------------------------------------- */ VIS$READ_CURRENT_LOCATION(x,y) unsigned int *x, *y; { return(-1); /* Bogus for now */ } /* --------------------------------------------------------------------- */ /* VIS$SET_SYNC_FORMAT (on) - */ /* - - */ /* - This procedure selects the sync format either - */ /* - interlaced or not - */ /* --------------------------------------------------------------------- */ VIS$SET_SYNC_FORMAT (on) int on; { } /* --------------------------------------------------------------------- */ /* VIS$GET_SYNC_FORMAT (info) - */ /* - - */ /* - This procedure gets the sync format - */ /* --------------------------------------------------------------------- */ VIS$GET_SYNC_FORMAT (info) int *info; { *info = 2; } /* ------------------------------------------------------------------ */ /* - VIS$WRITE_LINE (X, Y, DX, DIRECTION, VALUES) - */ /* - - */ /* - This routine writes a line of pixels in any direction into the - */ /* - array of words VALUES. The line begins at X, Y and contains - */ /* - DX pixels. DX must be positive. VALUES should be dimensioned - */ /* - to be at least DX words long. - */ /* ------------------------------------------------------------------ */ VIS$WRITE_LINE ( x,y,dx,direction, values ) int x, y, dx, direction; int *values; { return (-1); /* for now RWW */ } /* ------------------------------------------------------------------ */ /* - VIS$READ_LINE (X, Y, DX, DIRECTION, VALUES) - */ /* - - */ /* - This routine writes a line of pixels in any direction into the - */ /* - array of words VALUES. The line begins at X, Y and contains - */ /* - DX pixels. DX must be positive. VALUES should be dimensioned - */ /* - to be at least DX words long. - */ /* ------------------------------------------------------------------ */ VIS$READ_LINE ( x,y,dx,direction, values ) int x, y, dx, direction; int *values; { return (-1); /* for now RWW */ } /*------------------------------------------------------------------------*/ /* - VIS$SET_HMASK (mask) - */ /* - - */ /* - This routine sets the host plane R/W mask - */ /*------------------------------------------------------------------------*/ VIS$SET_HMASK(mask) int mask; { } /* end function */ /*------------------------------------------------------------------------*/ /* - VIS$GET_HMASK (mask) - */ /* - - */ /* - This routine gets the host plane R/W mask - */ /*------------------------------------------------------------------------*/ VIS$GET_HMASK(mask) int *mask; { *mask = 0; } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$OUT_LINEARIZE_LUT (set,member) - */ /* - - */ /* - This procedure linearizes an OUTPUT lut - */ /* --------------------------------------------------------------------- */ VIS$OUT_LINEARIZE_LUT(set,member) int set; /* - Used for i,r,g,b - */ int member; /* - Used for 0..15 - */ { switch (set) { case 0 : linlut(INPUT, member); break; case 1 : linlut(RED, member); break; case 2 : linlut(GREEN, member); break; case 3 : linlut(BLUE, member); break; } /* end case */ } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$SET_TRANSFER_MODE (mode) - */ /* - - */ /* - This routine sets the transfer mode of pixels - */ /* - mode = 0 for Z transfer mode (12 bits for each pixel) - */ /* - mode = 1 for X transfer mode (8 horizontally adjacent pixels ) - */ /* --------------------------------------------------------------------- */ VIS$TRANSFER_MODE (mode) int mode; { } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$PLANE_SELECT (plane) - */ /* - - */ /* - This routine selects the planes to be used in the - */ /* - the transfer mode (above) of pixels. This is only used in - */ /* - mode = 1 for X transfer mode (8 horizontally adjacent pixels ) - */ /* --------------------------------------------------------------------- */ VIS$PLANE_SELECT (plane) int plane; { } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$SUPER_Z_MODE (on) - */ /* - - */ /* - This routine sets the super Z mode on or off on = 1 off = 0 - */ /* --------------------------------------------------------------------- */ VIS$SUPER_Z_MODE (on) int on; { } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$ASSIGN_BIT_COLOR (member) - */ /* - - */ /* - This procedure assigns colors to each bit plane - */ /* --------------------------------------------------------------------- */ VIS$ASSIGN_BIT_COLOR (thickness, member) int thickness, member; { int i,j,n; int redval[256]; int blueval[256]; int greenval[256]; j = 0; redval[0] = 0; blueval[0] = 0; greenval[0] = 0; for (i=1; i<=255; i++) { switch (((i-1)/thickness) % 5) { case 0: /* red */ redval[i] = 0 /*255*/; blueval[i] = 255 /*0*/; greenval[i] = 0 /*255*/; break; case 1: /* white */ redval[i] = 255; blueval[i] = 255 /*255*/; greenval[i] = 255 /*255*/; break; case 2: /* blue */ redval[i] = 255 /*0*/; blueval[i] = 0 /*255*/; greenval[i] = 0; break; case 3: /* green */ redval[i] = 0; blueval[i] = 0; greenval[i] = 255; break; case 4: /* color */ redval[i] = 75; blueval[i] = 250; greenval[i] = 50; break; default: break; } } redval[255] = 255; /* set to white the last one */ blueval[255] = 255; greenval[255] = 255; /* special to see and debug color */ redval[254] = 45; blueval[254] = 70; greenval[254] = 70; redval[253] = 45; blueval[253] = 70; greenval[253] = 70; /* SELECTS THE member OUTPUT LUT IN FG101/640-2 BOARDS */ VIS$LOAD_LUT( 1, member, redval ); VIS$LOAD_LUT( 2, member, greenval ); VIS$LOAD_LUT( 3, member, blueval ); } /* end function */ /* --------------------------------------------------------------------- */ /* - VIS$DOWN_COPY_BLOCK (x1, y1, x2, y2, x_to, to_y) - */ /* - - */ /* - This routine copies a block of pixels down in the Frame Buffer - */ /* - To_y will be decremented by ones so this is the end of the block - */ /*-----------------------------------------------------------------------*/ VIS$DOWN_COPY_BLOCK (x1, y1, x2, y2, to_x, to_y) int x1, y1, x2, y2, to_x, to_y; { } /* end function */ #endif