#! /usr/bin/gawk -f # Last edited on 2014-01-28 20:08:10 by stolfilocal # A {gawk} library function to write a ".fni" image (see {float_image.h}). # To be included into other {gawk} programs with "-f". function write_fni_image(NC,NX,NY,img,fname) { # Writes to {fname} the float array {img} as a float image in ".fni" format. # Assumes {imh[c,x,y]} is the sample in color channel {c}, # pixel column {x}, and pixel row {y} of the image, # for {c} in {0..NC-1}, {x} in {0..NX-1}, and {y} in {NY-1}. printf "begin float_image_t (format of 2006-03-25)\n" > fname; printf "NC = %d\n", NC > fname; printf "NX = %d\n", NX > fname; printf "NY = %d\n", NY > fname; for (y = 0; y < NY; y++) { for (x = 0; x < NX; x++) { printf "%5d %5d", x, y > fname; for (c = 0; c < NC; c++) { printf " %+14.7e", img[c,x,y] > fname; } printf "\n" > fname; } printf "\n" > fname; } printf "end float_image_t\n" > fname; fflush(fname); }