Google Answers Logo
View Question
 
Q: Imaging - Create RAW file with pixel values ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Imaging - Create RAW file with pixel values
Category: Computers > Graphics
Asked by: richard1776-ga
List Price: $25.00
Posted: 23 Sep 2002 17:11 PDT
Expires: 23 Oct 2002 17:11 PDT
Question ID: 68244
We wrote a program that outputs a text file with a series of numbers
from 0 to 255 whereby 0 is black and 255 is the whitest white. The
numbers in between are shades of grey. There is a number (0-255) to
represent each pixel in an image 640 x 480 (307,200 total values; a
hard return after 640 values; 480 rows). We
want to take these values and create a grey-scale image. We have
Photoshop 7 and Paint Shop Pro 6, but we can't seem to get there.
Should we create a *.RAW file with these values that could then be
opened by Paint Shop Pro and saved to a jpeg? How would I do this? Any
approach that works would be acceptible.
Answer  
Subject: Re: Imaging - Create RAW file with pixel values
Answered By: maniac-ga on 23 Sep 2002 17:53 PDT
Rated:5 out of 5 stars
 
Hello Richard1776,

You did not specify which operating system you are using (or have
access to) so I will provide a set of suggestions that should meet
your need.

First - you may be able to use what you have. Some examples I found
with similar tasks include:
[export from an application, import to Photoshop 5]
  http://www.3dartist.com/WP/pullsdts/rawex1.htm
[import and composite data from an application]
  http://www.nps.gov/carto/silvretta/bryce/large.html
[processing 12 bit gray scale with Photoshop]
  http://www.aecom.yu.edu/aif/instructions/12bit.htm
These examples also have hints on improving the image quality.

If one of these do not work, perhaps the most flexible image
conversion application I have used is "convert". I use it for
converting screen capture to postscript (to embed in documentation or
printing), but it supports over 60 image formats. You can find it on a
number of Unix or Linux distributions - usually as part of a package
called "ImageMagick", but versions are available on both Mac OS 9 and
X or on Windows (95, 98, NT, 2000, ...). Its home page is at...
  http://www.imagemagick.org/
The convert application is described at
  http://www.imagemagick.org/www/convert.html
and includes an example (the fifth one) of converting raw gray scale
data into another form. It also has the advantage of being free.

On Macintosh OS 9, there are utilities such as Image (originally from
NIH, now also from Scion - also PC version)
  http://rsb.info.nih.gov/nih-image/
  http://www.scioncorp.com/frames/fr_scion_products.htm (scroll
down...)
with an example from the Macintosh application illustrated at
  http://www.nist.gov/lispix/imlab/Raw_fmt/import.html
The raw import is the second example.

If you are still looking for similar applications or need further
explanation, ask with a clarification request or search with phrases
such as
  gray scale raw import
  grayscale raw import
and include the operating system name if necessary.

For example, if you are using Mac OS X, want to use convert, and are
not familiar with the command line interface - please ask. I can walk
you through the process.

  --Maniac

Request for Answer Clarification by richard1776-ga on 25 Sep 2002 14:08 PDT
Hello Maniac,
Thank you for answering my question. I use Windows XP Home so I
focused on your answers dealing with Windows. After reviewing the
various approaches, I think that using the convert utility will do the
trick. You mentioned at the bottom that you would be willing to walk
me through the command line. I am using a small test file that is only
64x48 pixels.

I enter this command:
convert -depth 8 -size 64x48+128 gray:testdata1.txt testdata1.jpeg

and get:
Unexpected end-of-file (testdata1.txt)

Could this be because I am guessing wrong on the header size (+128)?
BTW: When I opened the text file using ImageMagic it put the file name
and path into the text file.

Am I on the right track?

Richard

Clarification of Answer by maniac-ga on 25 Sep 2002 16:56 PDT
Hello Richard1776,

Hmm. Based on your original description, you do not have any header
information in the data file. If the 64 x 48 file is 3072 bytes long,
then leave off the +128 from the example. In a similar manner, if the
640 x 480 pixel file is 307200 bytes long (it may be shown as 300
kbytes), the same applies with the full sized file.

If not these sizes, then there is some header information that needs
to be skipped. It may be as simple as the difference in size between
the raw image size (e.g., 3072) and the actual file size (e.g., 3140)
to get a header size of 68 bytes.

If not so simple, then some additional analysis may be necessary. A
utility such as "hexview" described at
  http://www.funduc.com/text/
can be helpful. It is a little over half the way down the list of
applications and is free. You can use a utility like this to decode
the data to determine the size of the header and confirm your
understanding of the image data contained in the file.

  --Maniac
richard1776-ga rated this answer:5 out of 5 stars

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy