From: Jérôme Hénin (jerome.henin_at_uhp-nancy.fr)
Date: Mon Mar 13 2006 - 07:33:11 CST

Hi Nuno,

I use ImageMagick as a very convenient way to do what you suggest. Here is the
part of my awk script that does the image writing. The array 'color' is used
to associate RGB values to my raw data (in the 'struct' array).

--------
        # Pipe PPM image data to convert to make a PNG
        conv = "convert - " name ".png"

        printf "P3 %i %i 255\n", NR, height * residues | conv

        # last residue at the top, first at the bottom
        for (r=residues; r>=1; r--) for (i=1; i<=height; i++) {
            for (t=1; t<=NR; t++) {
                print color[struct[t, r]] | conv
            }
        }

        close(conv)
--------

So I use the ASCII PPM format, but because of the piping capability of GNU
awk, I don't even have to actually write the PPM file on disk.

Best,
Jerome

Le Samedi 11 Mars 2006 20:05, Nuno R. L. Ferreira a écrit :
> Hi *
>
> I'm calculating some properties on a trajectory, using VMD in batch mode.
> Some of these properties are ascii matrices, like a Calpha distance map
> (matrix has real numbers) or secondary structure vs time (matrix contains
> stride code letters; nº rows == nº residues).
>
> How do I convert this plain matrices to an image?
> I though that the best way was to produce a raster file (like .ppm or
> .xpm), and then use ImageMagick or NetPBM programs to convert the text file
> to a more appropriate image format, like .png.
>
> To do that, I need some scripting.
> If I want to get a .ppm (or netpbm like) file, I need to convert each
> matrix entry to an RGB code. In the .xpm case, I need to convert the matrix
> entries to a code, which is then coupled to a color via a code on the
> header of the file.
>
> Do you guys ever tryed to do that? Is this a good approach?
>
> Best regards,
> N.
>
>
>
> ######################################
> Nuno Ricardo Santos Loureiro da Silva Ferreira
> Departamento de Química
> Faculdade de Ciências e Tecnologia
> Universidade de Coimbra
> 3004-535 Coimbra - Portugal
> Fax: +351 239 827703 - www.biolchem.qui.uc.pt
> ########################################
>
>
>
> ---
> avast! Antivirus: Outbound message clean.
> Virus Database (VPS): 0610-2, 10-03-2006
> Tested on: 11-03-2006 19:05:11
> avast! - copyright (c) 1988-2005 ALWIL Software.
> http://www.avast.com

-- 
Jérôme Hénin
Equipe de Dynamique des Assemblages Membranaires
Université Henri Poincaré / CNRS
Tel : (33) 3 83 68 43 91        Fax : (33) 3 83 68 43 87
http://www.edam.uhp-nancy.fr/