Image from text

Hi all,

I wanted to take the some of the -o outputs of rtrace and feed it to a couple of scripts that would modify the output based on a the rtrace parameters. However, I don't have a good method of turning that ASCII text back into an image (aside from PIL, ImageMagick, and the ra_* commands). Is there a way to take a series of numbers/values and convert it to a Radiance picture, like rpict with the ability to input data instead of a scene? If so, which values would I need?

Thanks in advance,

--Dave

Hi,

take a look at pvalue, especially the -r option. Pvalue allows you to
convert from radiance pictures to ascii or binary representations of the
pixel values - or vice verse, what is what you need here.

Besides that, ppm greyscale files can be written easily :wink: They are
ascii....

CU Lars.

Ah, thanks, pvalue does the trick.

Two things of note though which I don't think are documented: It looks like pvalue needs the ASCII input to have a Radiance header - at least "#?RADIANCE" on the first line followed by a blank line. In the command "pvalue -h image.hdr | pvalue -r > image2.hdr" the second pvalue will not know what to do with the output from the first pvalue.

Also, the -d switch on pvalue works on the reverse operation as well. If you do something like "pvalue -d image.hdr | pvalue -r > image2.hdr", the second pvalue will use the header to determine the dimensions but ignore the red and green columns (assuming they were supposed to be x and y), so you'll get only the blue channel in image2.hdr. However, "pvalue -d image.hdr | pvalue -r -d > image2.hdr" will reproduce the original image. This behavior is noted in the Bugs section but not in the description for the -d option.

--Dave

Hi Dave,

You need to read the pvalue man page a little more closely. You can feed it an ASCII file with no header by employing the -h option together with -H to say there is no resolution string, but then you need to use -y YRES +x XRES options to specify the image resolution and scanline ordering.

Best,
-Greg

ยทยทยท

From: [email protected]
Date: January 30, 2009 7:49:39 AM PST

Ah, thanks, pvalue does the trick.

Two things of note though which I don't think are documented: It looks like pvalue needs the ASCII input to have a Radiance header - at least "#?RADIANCE" on the first line followed by a blank line. In the command "pvalue -h image.hdr | pvalue -r > image2.hdr" the second pvalue will not know what to do with the output from the first pvalue.

Also, the -d switch on pvalue works on the reverse operation as well. If you do something like "pvalue -d image.hdr | pvalue -r > image2.hdr", the second pvalue will use the header to determine the dimensions but ignore the red and green columns (assuming they were supposed to be x and y), so you'll get only the blue channel in image2.hdr. However, "pvalue -d image.hdr | pvalue -r -d > image2.hdr" will reproduce the original image. This behavior is noted in the Bugs section but not in the description for the -d option.

--Dave