Search:

Summary | Source files | Compilation | Precompiled | References

EpsImg

Given a matrix of floating-point numbers stored in a regular ASCII text file, the EpsImg program creates a grey-scale Encapsulated PostScript (EPS) image of the matrix using its elements as specification of the brightness of the corresponding pixels in the image. For an extensive description of the algorithms used in the program, supported command-line options and syntax, as well as the full documentation of the source, see epsimg.pdf. [195 kB, 28 pages].

Summary of the program

As for this program, I do by no means claim to have optimized the generated Encapsulated PostScript. The output images are in many cases large, and could in many cases be considerably reduced in size, in particular for binary or few-level grayscale images for which run-length encoding easily can be applied. (In run-length encoding a long row of identical pixels is parametrized as a loop, without the need of individual specification of each pixel.) However, for my purposes it works fine, since I often only is concerned with the evaluation of gray-scale images, generated by mathematical means and often with no a priori specification of the number of intensity levels.

Of course, there are other ways of generating Encapsulated PostScript images of sampled of simulated data, as for example using the image() function of MATLAB. However, an advantage with using a stand-alone program is that it is easily incorporated in scripts for batch processing. In addition, the EpsImg program is provided free of charge.

example

Figure 1. Example of application of the EpsImg program, in this particular case for the visualization of a two-dimensional artificially generated interference pattern. The numerical data for the image was generated by an AWK script and stored in an ASCII file example1.dat. The Encapsulated PostScript image was then generated by a call of the EpsImg program, with command-line parameters of the form epsimg -i example1.dat -o example1.eps, to leave the image file example1.eps.

Extract of Makefile for the generation of Fig. 1:


#
# Example 1: In the following example, a simple interference
#            pattern from two point sources is generated with
#            the help of a AWK script, and the generated data
#            (example.dat) are visualized as an Encapsulated
#            PostScript image (file example.eps), created by a
#            single call to the EPSIMG program.
#                  To compare the generated images with those
#            generated by the MATLAB routine `image()', execute
#            the MATLAB blocks
#                    colormap(gray);
#                    w=load('example1.dat');
#                    w=w-min(min(w));
#                    w=64*w./max(max(w));
#                    image(w);
#                    print('-deps','slask.eps');
#
example1:
    echo "0"|awk 'BEGIN {nr=64; nc=64; a=2.0} {\
        for (j=1;j<=nr;++j) {\
            for (k=1;k<=nc;++k) {\
         x=7*(j-nr/2)/nr;\
         y=7*(k-nc/2)/nc;\
         f=sin((x-a)*(x-a)+y*y)+sin((x+a)*(x+a)+y*y);\
         printf("%-1.3f ",f);\
            }\
            printf("\n");\
        }\
    } END {}' > example1.dat
    epsimg -v --compactified_pixelcode --uncommmented_postscript \
        -i example1.dat -o example1-compact.eps
    epsimg -v --extensive_pixelcode --uncommmented_postscript \
        -i example1.dat -o example1-extensive.eps

Current revision

Revision 1.6, as of 21/02/2004. Copyright © Fredrik Jonsson 2003-2006, under GPL

Source files

epsimg.pdf [195 kB] Documentation of the EpsImg program in Portable Document Format (PDF) [2], generated from the PostScript [4] documentation.

epsimg.w [44 kB] The CWEB [1] master source code for the EpsImg program. From this master, the ANSI-C (ISO C90) source code for the program and TeX code for the documentation is extracted using the CTANGLE and CWEAVE compilers, respectively.
[ download | view source ]

Makefile [2 kB] The Makefile for compilation of the executable file, as well as generation of the documentation of the program. Extracts the C and TeX code from the CWEB source, and compiles the C and TeX code into binary executable and PostScript, respectively. To compile the executable and documentation, simply run 'make' in the directory containing the source files and this Makefile.
[ download | view source ]

epsimg.c [16 kB] ANSI-C (ISO C90) conforming source code, extracted from the CWEB master source code using the CTANGLE program by Donald E. Knuth.
[ download | view source ]

epsimg.tex [56 kB] Plain TeX [3] source code, extracted from the CWEB master source code using the CWEAVE program by Donald E. Knuth.
[ download | view source ]

epsimg.ps [506 kB] PostScript [4] documentation of the EpsImg program, generated from the TeX-code, which in turn is generated from the CWEB master source code.

Compilation

Compile the CWEB [1] code 'epsimg.w' using the enclosed Makefile, or use the blocks of the Makefile as listed in section 3 of the documentation.

The EpsImg program is written in CWEB, generating ANSI-C (ISO 9899/C90) conforming source code and documentation as plain TeX-source, and is to be compiled using the sequences as outlined in the enclosed Makefile. The Makefile essentially executes two major calls. First, the CTANGLE program parses the CWEB source document 'epsimg.w' to extract a ANSI-C source file 'epsimg.c', which may be compiled in the usual way using any ANSI-C conformant compiler. The output source file includes #line specifications so that any debugging can be done conveniently in terms of the original CWEB source file. Second, the CWEAVE program parses the same CWEB source file to extract a plain TeX source file 'epsimg.tex' which may be compiled in the usual way. It takes appropriate care of typographic details like page layout and the use of indentation, italics, boldface, and so on, and it supplies extensive automatically gathered cross-index information.

After having executed make in the same catalogue where the files epsimg.w and Makefile are located, one is left with an executable file epsimg, being the ready-to-use compiled program, and a PostScript file epsimg.ps which contains the full documentation of the program. Notice that on platforms running Windows NT, Windows 2000, Windows ME, or any other operating system by Microsoft, the executable file will instead automatically be called epsimg.exe. This convention also applies to programs compiled under the UNIX-like environment CYGWIN.

Precompiled executables

epsimg [24 kB] Executable program compiled for Mac OS X using the GNU C Compiler (GCC).

References

[2] For information on the Portable Document Format (PDF) of Adobe, see for example the homepage of Adobe Systems Inc., at http://www.adobe.com/products/acrobat/

[3] For information on the TeX typesetting system, as well as on the dvips program, see for example the website of the TeX Users Group, at http://www.tug.org

[4] For information on the PostScript programming language, see for example the PostScript area on the website of Adobe Systems Inc., at http://www.adobe.com/products/postscript/ or the reference book "PostScript Language - Tutorial and Cookbook" (Adison-Wesley, Reading, Massachusetts, 1985), ISBN 0-201-10179-3.

Return to previous page

Leave a message

Your name:

Your email: (required)

Message:

Generated by ::emailform::

Last modified 15 Dec 2009