Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-06 - 43,50416/tk4023.sai
There are 2 other files named tk4023.sai in the archive. Click here to see a list.
entry ;
Begin
COMMENT
.SEC(TK4023.SAI - Gray scale display package)
.index(TK4023.SAI - Gray scale display package)

file: TK4023.sai
TK4023: Subroutine for displaying halftone pictures 
on a Tektronix 4023 terminal. Written by:

                         Richard Gordon
                     Image Processing Unit
                   National Cancer Institute
                 National Institutes of Health
                     Building 36, Room 4D28
                  Bethesda, Maryland 20014 USA



Revised April 13, 1976 - Lemkin, Shapiro - cleaned up and LCS check.
The following parameters must be passed:

title_ an ASCII String
subtitle_ an ASCII String
(x0,y0)_ the coordinates of the lower left hand corner of the
         picture in the user's coordinate system.
pict_ an Integer mode Array dimensioned 
      pict[0:nrows-1,0:ncolumns-1]
nrows_ number of rows
ncolumns_ number of columns
dnsmin _ minimum density of Array pict
dnsmax _ maximum density of Array pict
         note: if dnsmin geq dnsmax then the minimum and
         maximum densities are calculated from pict
scaling_ 0 for linear scaling, otherwise the ratio
         between the brightnesses of the maximum and minimum
         densities
film _ "neg" for a negative
       "pos" for a positive
npict_ the number to be assigned to the picture

WARNING: the first and last sets of blank rows are trimmed.
Other blank rows will not be seen if TTY parameter NO BLANK is set.
;



    Internal Procedure TK4023(  String title,subtitle;
                                Real x0,y0;
                                Integer Array pict;
                                Integer nrows,ncolumns,dnsmin,dnsmax;
                                Real scaling;
                                String film;
                                Integer npict  );
    Begin "TK4023"

Require "DEFINE.REQ" source!file;
        Real scale,range;

        Integer dmin,dmax,i,j,density,last!row,last!column,Ending,
            first!nonblank!row,last!nonblank!row;

        Integer Array line[0:ncolumns];

        boolean negative;

"The Array c[density] specifies which character is to
be typed for the given density" preload!with 63,63,63,63,63,56,32,36,46,
            42,57,57,40,50,54,54,52,52,55,53,41,41,41,41,41,60,60,60,60,
            60,60,60,60,60,60,60,60,60,60,60,61;
        own Integer Array c[0:40];
"carriage return and line feed:"
        last!row_nrows-1;
        last!column_ncolumns-1;
comment Density scaling for "pict";
        dmin_dnsmin;
        dmax_dnsmax;
        if  dmax leq dmin
        then
        Begin "calculating minimum and maximum"
            dmin_maxInteger;
"=largest Integer in one word"
            dmax_-dmin;
            for i_  0 step 1 until last!row do
                for j_  0 step 1 until last!column do
                Begin "find extrema"
                    density_pict[i,j];
                    dmin_dmin min density;
                    dmax_dmax max density;
                End "find extrema";
            if  dmax leq dmin
            then
            Begin "no picture"
                outstr(title & " " & subtitle & " is all constant" &
                    crlf);
                return;
            End "no picture";
        End "calculating minimum and maximum";
        range_dmax-dmin;
        scale_40./(dmax-dmin);
        negative_ if  equ(film[1 for 1],"n") or equ(film[1 for 1],"N")
                  then true
                  else false;
        for first!nonblank!row_0 step 1 until last!row do
        Begin "looking for first nonblank row"
            for j_  0 step 1 until last!column do
            Begin "scan row"
                density_ if  scaling=0
                         then scale*(pict[j,first!nonblank!row]-dmin)
                         else 40*scaling^(((dmin max (dmax min pict[j,
                                 first!nonblank!row]))-dmax)/range);
                if  negative
                then density_40-density;
                density_0 max (40 min density);
                if  density>4
                then done

"looking for first nonblank row"
                ;
            End "scan row";
        End "looking for first nonblank row";
        for last!nonblank!row_last!row step -1 until first!nonblank!row
            do
        Begin "looking for last nonblank row"
            for j_  0 step 1 until last!column do
            Begin "scan row"
                density_ if  scaling=0
                         then scale*(pict[j,last!nonblank!row]-dmin)
                         else 40*scaling^(((dmin max (dmax min pict[j,
                                 last!nonblank!row]))-dmax)/range);
                if  negative
                then density_40-density;
                density_0 max (40 min density);
                if  density>4
                then done

"looking for last nonblank row"
                ;
            End "scan row";
        End "looking for last nonblank row";
comment Create halftone picture.;
        for i_  first!nonblank!row step 1 until last!nonblank!row do
        Begin "row"
            for j_  0 step 1 until last!column do
            Begin "build row"
                density_ if  scaling=0
                         then scale*(pict[i,j]-dmin)
                         else 40*scaling^(((dmin max (dmax min pict[i,j]))
                                 -dmax)/range);
                if  negative
                then density_40-density;
                density_0 max (40 min density);
                line[j]_c[density];
            End "build row";
            for Ending_last!column step -1 until 0 do
                if  line[Ending] neq 63
                then done ;
            Begin "line output"
                outstr(14);
                for j_  0 step 1 until Ending do
                    outstr(line[j]);
                outstr(15 & crlf);
            End "line output";
        End "row";
        outstr(title & " " & subtitle & crlf);
    End "TK4023";

End;