home *** CD-ROM | disk | FTP | other *** search
/ vis-ftp.cs.umass.edu / vis-ftp.cs.umass.edu.tar / vis-ftp.cs.umass.edu / pub / Software / ASCENDER / ascendMar8.tar / UMass / BoldtNew / LLVS / extractpl.c < prev    next >
C/C++ Source or Header  |  1996-01-31  |  3KB  |  93 lines

  1. /*
  2.  * ------------------------------------------------------------------
  3.  * extractpl.c - Function to extract a sub-image
  4.  * Created by Robert Heller on Wed Feb  5 08:30:11 1992
  5.  * ------------------------------------------------------------------
  6.  * Modification History:
  7.  * ------------------------------------------------------------------
  8.  * Contents:
  9.  * ------------------------------------------------------------------
  10.  *  
  11.  * Copyright (c) 1992 by University of Massachuetts
  12.  *     All Rights Reserved
  13.  * 
  14.  */
  15.  
  16. #include <stdio.h>
  17. #include <llvs_per_plane.h>
  18.  
  19. void extract_plane(inplane,inplane_info,outplane,outplane_info,limits)
  20. PLANE *inplane, *outplane;
  21. PLANE_INFO *inplane_info, *outplane_info;
  22. LIMITS *limits;
  23. {
  24.     int runlevel, indeltalev, outdeltalev;
  25.     int current_row, current_column, in_row, in_col, out_row, out_col;
  26.     int ipixel, iback;
  27.     float fpixel, fback;
  28.  
  29.     /* compute delta level */
  30.     runlevel = limits->level;
  31.     indeltalev = runlevel - inplane_info->level;
  32.     outdeltalev = runlevel - outplane_info->level;
  33.     /* grab background value */
  34.     if (inplane_info->datatype == FLOAT) {
  35.         fback = inplane_info->background.flonum;
  36.  
  37.         /* row loop */
  38.         for (current_row = limits->startrow;
  39.              current_row <= limits->endrow;
  40.              current_row += limits->deltarow) {
  41.             /* translate row offset */
  42.             TRANSLEVEL(in_row, current_row, indeltalev,
  43.                        inplane_info->row_location);
  44.             TRANSLEVEL(out_row, current_row, outdeltalev,
  45.                        outplane_info->row_location);
  46.             /* column loop */
  47.             for (current_column = limits->startcol;
  48.                  current_column <= limits->endcol;
  49.                  current_column += limits->deltacol) {
  50.                 /* translate column offsets */
  51.                 TRANSLEVEL(in_col, current_column, indeltalev,
  52.                        inplane_info->column_location);
  53.                 TRANSLEVEL(out_col, current_column, outdeltalev,
  54.                        outplane_info->column_location);
  55.                 /* fetch pixel */
  56.                 GET_PIXEL(fpixel, fback, inplane, in_row,
  57.                       in_col,(*inplane_info));
  58.                 SET_PIXEL(fpixel, outplane, out_row, out_col,
  59.                       (*outplane_info));
  60.             }
  61.         }
  62.     } else {
  63.         iback = inplane_info->background.fixnum;
  64.  
  65.         /* row loop */
  66.         for (current_row = limits->startrow;
  67.              current_row <= limits->endrow;
  68.              current_row += limits->deltarow) {
  69.             /* translate row offset */
  70.             TRANSLEVEL(in_row, current_row, indeltalev,
  71.                        inplane_info->row_location);
  72.             TRANSLEVEL(out_row, current_row, outdeltalev,
  73.                        outplane_info->row_location);
  74.             /* column loop */
  75.             for (current_column = limits->startcol;
  76.                  current_column <= limits->endcol;
  77.                  current_column += limits->deltacol) {
  78.                 /* translate column offsets */
  79.                 TRANSLEVEL(in_col, current_column, indeltalev,
  80.                        inplane_info->column_location);
  81.                 TRANSLEVEL(out_col, current_column, outdeltalev,
  82.                        outplane_info->column_location);
  83.                 /* fetch pixel */
  84.                 GET_PIXEL(ipixel, iback, inplane, in_row,
  85.                       in_col,(*inplane_info));
  86.                 SET_PIXEL(ipixel, outplane, out_row, out_col,
  87.                       (*outplane_info));
  88.             }
  89.         }
  90.     }
  91. }
  92.  
  93.