producing black and white synthetic image

Jun 2, 2011 at 9:28pm
May I know how can we produce a black and white synthetic image with some noise?
Jun 2, 2011 at 10:51pm
Yes. Get a big piece of paper. Sprinkle some white paint on it, and then some black. Done.
Jun 3, 2011 at 1:28am
Do you really mean two-color or do you mean grayscale?
Use a random number generator, and fill the pixels that way.
Save the image to disk.
Jun 3, 2011 at 5:48pm
:) What I meant was, how to produce a grayscale image?
Jun 3, 2011 at 11:19pm
Well, using a standard RGB system, setting the red, green, and blue components to the same value will produce a gray color. e.g. (R=0,G=0,B=0) means black, (R=255,G=255,B=255) means white, and all the values in between increase in brightness incrementally between 0 and 255.

Note that images could be RGBA, they could vary in bits per pixel, bits per color component, some have been compressed (with or without loss), etc. Not to mention every image format varies in the way they store the actual pixels and their supplementary data such as pallettes.

For example, examine the differences between BMP and JPEG (scroll down to syntax and structure and onward):

http://en.wikipedia.org/wiki/BMP_file_format
http://en.wikipedia.org/wiki/JPEG

If you want to work with images from scratch, I would suggest targeting an easier format such as GIF or BMP (Windows built-ins can be used as a good shortcut for working with BMPs). Otherwise, I would recommend using a library (such as CImg or DevIL). I haven't used any of those libraries so I can't comment on their efficacy.
Jun 4, 2011 at 2:33am
An image is really just a two-dimentional array of color values. What matters is how you use it. Do you plan to display the image, or do you only want to save it to disk?
Jun 6, 2011 at 7:34am
I am planning to model up a gray scale image (radiographic) with some object using Beer–Lambert Law. I'm thinking of producing a synthetic image of X-ray image.
Jun 6, 2011 at 10:39pm
Both BMP and TGA files are very easy to produce. If you use a library, like libpng, you can produce something more compact, like a PNG.
Topic archived. No new replies allowed.