Re: [math-fun] Changing photos into matrices
What you want is a so-called "bitmap" image, with no compression whatsoever. On Windows machines this is a ".bmp" image. There is another issue, which is the "color space" issue. Even after converting into individual pixels, you still need to know how these pixels map into colors. Luckily, your image is grayscale only, so you shouldn't have to worry about that. Most "bitmapped" images have 8 bits of grayscale, which may not be sufficient to represent finely shaded images. As a result, you could get "contouring" where the gray scale values change integrally. This can be fixed (at some loss of resolution) by "halftoning". Alternatively, there are so-called "raw" bitmap formats for modern cameras which can represent more than 8 bits of grayscale per pixel. I believe that the free "gimp" software will do this (and a lot more). http://www.gimp.org/ At 11:54 AM 2/25/2014, James Propp wrote:
Does anyone know a way to turn black and white jpeg images into rectangular arrays of pixel-by-pixel grayscale levels?
My Mac has Adobe Photoshop CS6 and Mathematica, but I can't figure out a way to get either of them to do it.
The reason I want to do this has to do with this year's Gathering for Gardner, so I believe it (just barely) qualifies as a math-fun topic.
Jim Propp
jpegtopnm is on virtually any linux box, or can be installed as part of the netpbm tools. The pgm format (what you get from a greyscale jpeg) is almost self-documenting (but there is a man page). It's probably not hard to compile it for the Mac. -tom On Tue, Feb 25, 2014 at 1:13 PM, Henry Baker <hbaker1@pipeline.com> wrote:
What you want is a so-called "bitmap" image, with no compression whatsoever.
On Windows machines this is a ".bmp" image.
There is another issue, which is the "color space" issue. Even after converting into individual pixels, you still need to know how these pixels map into colors.
Luckily, your image is grayscale only, so you shouldn't have to worry about that.
Most "bitmapped" images have 8 bits of grayscale, which may not be sufficient to represent finely shaded images. As a result, you could get "contouring" where the gray scale values change integrally. This can be fixed (at some loss of resolution) by "halftoning".
Alternatively, there are so-called "raw" bitmap formats for modern cameras which can represent more than 8 bits of grayscale per pixel.
I believe that the free "gimp" software will do this (and a lot more).
At 11:54 AM 2/25/2014, James Propp wrote:
Does anyone know a way to turn black and white jpeg images into rectangular arrays of pixel-by-pixel grayscale levels?
My Mac has Adobe Photoshop CS6 and Mathematica, but I can't figure out a way to get either of them to do it.
The reason I want to do this has to do with this year's Gathering for Gardner, so I believe it (just barely) qualifies as a math-fun topic.
Jim Propp
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
-- -- http://cube20.org/ -- http://golly.sf.net/ --
participants (2)
-
Henry Baker -
Tom Rokicki