home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 293_02 / dump.c < prev    next >
C/C++ Source or Header  |  1989-08-25  |  2KB  |  85 lines

  1.              /* dump.c */
  2. /*************************************************************
  3.  
  4.       3-D Reconstruction of Medical Images
  5.  
  6.     Three Dimensional Reconstruction Of Medical
  7.     Images from Serial Slices - CT, MRI, Ultrasound
  8.  
  9.  
  10.    These programs process a set of slices images (scans) for one
  11.    patient. It outputs two sets of files containing nine predefined
  12.    views of bony surfaces. One set contains distance values and
  13.    the other gradient values.
  14.  
  15.    The distance values are used as 3-D spatial topographic surface
  16.    coordinate maps for geometrical analysis of the scanned object.
  17.  
  18.    The gradient values are used for rendering the surface maps on
  19.    CRT displays for subjective viewing where perception of small
  20.    surface details is important.
  21.  
  22.     Daniel Geist, B.S.
  23.     Michael W. Vannier, M.D.
  24.  
  25.     Mallinckrodt Institute of Radiology
  26.     Washington University School of Medicine
  27.     510 S. Kingshighway Blvd.
  28.     St. Louis, Mo. 63110
  29.  
  30.     These programs may be copied and used freely for non-commercial
  31.     purposes by developers with inclusion of this notice.
  32.  
  33.  
  34. ********************************************************************/
  35.  
  36. #include <stdio.h>
  37. /* #include <stdlib.h> */
  38. #include <ctype.h>
  39.  
  40. unsigned char buffer[256];
  41.  
  42.  
  43. main(argc,argv)
  44.  
  45. int argc;
  46. char *argv[];
  47.  
  48.     int i,j,k,read=256;
  49.     FILE *fn;
  50.  
  51.     if (argc<2) error_exit("no file given");
  52.     fn=fopen(argv[1],"rb");
  53.     if(fn==0) error_exit("could not open file");
  54.     if(argc>2) 
  55.     { 
  56.         j=atoi(argv[2]);
  57.         if (j>0) for(i=0;i<j;i++) read=fread(buffer,1,256,fn);
  58.         else j=0;
  59.     }
  60.     else j=0;
  61.     
  62.      while(read==256)
  63.      {
  64.         printf(" \n\n               block no. %d\n\n",j++);
  65.         read=fread(buffer,1,256,fn);
  66.         for (i=read;i<256;i++) buffer[i]=0;
  67.         for (i=0;i<16;i++)
  68.     {
  69.             for(k=0;k<16;k++) printf(" %.2X",buffer[i*16+k]);
  70.             printf("   ");
  71.             for (k=0;k<16;k++) 
  72.                 putchar(isprint(buffer[i*16+k])?buffer[i*16+k]:'.');    
  73.             printf("  %.3d\n",i*16);
  74.         }
  75.     } 
  76. }
  77.  
  78. error_exit(message)
  79. char *message;
  80.     printf("DUMP -- %s\n",message);
  81.     exit(0);
  82. }
  83.