example6histogram.gri

# This html document was prepared by gri2html based on the Gri script named
# example6histogram.gri
# Gri is available for free at http://gri.sourceforge.net

    # Example 6 -- Plot IR image of Gulf of Maine

    # define characteristics of norda images
    \0val = "5"			# 0 in image
    \255val = "30.5"		# 255 in image
    .rows. = 128
    .cols. = 128
    .pixel_width. = 2
    .km. = {rpn .cols. .pixel_width. *}

    # get filenames
    query \filename "Name image file" ("example6image.dat")
    query \maskname "Name mask  file" ("example6mask.dat")

    # get data
    open \filename binary uchar
    set image range \0val \255val
    read image .rows. .cols. box 0 0 .km. .km.
    close
    open \maskname binary uchar
    read image mask .rows. .cols.
    close

    # find out what grayscale method to use
    query \histo "Do histogram enhancement? (yes|no)" ("yes")
    query \minT  "T/deg for white on page?          " ("10")
    query \maxT  "T/deg for black on page?          " ("15")
    \incT = "1"

    # set up scales.
    set x size 12.8
    set y size 12.8
    set x name "km"
    set y name "km"
    set x axis 0 .km. 32
    set y axis 0 .km. 32

    # plot image, grayscale, and histogram
    if {"\histo" == "yes"}
        set image grayscale using histogram black \maxT white \minT
    else
        set image grayscale black \maxT white \minT
    end if
    draw image
    draw image palette left \minT right \maxT increment \incT
    draw image histogram
    if {"\histo" == "yes"}
        draw title "Example 6: grayscale histogram enhanced"
    else
        draw title "Example 6: grayscale linear \minT to \maxT"
    end if