
Hello! I need to write a function in Haskell, which 1) reads a greyscale image (for instance, in JPEG, PNG or the like) and 2) transforms it into a n X m matrix A, where Aij contains an integer value (in the range 0 to 255). That integer value is zero for a completely black pixel, 255 for a completely white pixel and lies between zero and 255 for a grey pixel. In my program, I need ONLY to read an image and to transform it into such matrix. Which graphics library can you recommend, if no other image manipulation operations are required? TIA Dmitri Pissarenko -- Dmitri Pissarenko Software Engineer http://dapissarenko.com

Dmitri Pissarenko wrote:
I need to write a function in Haskell, which
1) reads a greyscale image (for instance, in JPEG, PNG or the like) and
If you can specify any image format you want, and you're not concerned with efficiency, you can't beat the simplicity of the portrable greymap (PGM) file format. You read in a simple header with the dimensions of the image, and one 8 bit character per pixel. http://www-info2.informatik.uni-wuerzburg.de/mitarbeiter/wolfram/lehre/bildf... Greg Buchholz

Greg Buchholz
I need to write a function in Haskell, which 1) reads a greyscale image (for instance, in JPEG, PNG or the like) and
If you can specify any image format you want, and you're not concerned with efficiency, you can't beat the simplicity of the portrable greymap (PGM) file format.
There are also variants using black and white (PBM) and color (PPM) and they also have textual value representations. Google for Andrew Cooke's pages, he has some code for reading/writing them as part of Pancito, IIRC. -kzm -- If I haven't seen further, it is by standing in the footprints of giants

On Thursday 20 Jan 2005 7:35 pm, Dmitri Pissarenko wrote:
Hello!
I need to write a function in Haskell, which
1) reads a greyscale image (for instance, in JPEG, PNG or the like) and
2) transforms it into a n X m matrix A, where Aij contains an integer value (in the range 0 to 255). That integer value is zero for a completely black pixel, 255 for a completely white pixel and lies between zero and 255 for a grey pixel.
In my program, I need ONLY to read an image and to transform it into such matrix.
Which graphics library can you recommend, if no other image manipulation operations are required?
These might help.. http://homepages.nildram.co.uk/~ahey/HLibs/Multimedia.SDL.Core/ http://homepages.nildram.co.uk/~ahey/HLibs/Multimedia.SDL.Image/ What you'll get is an SDL surface (C data structure), so you'll have to write some code to read it if you want a Haskell array. Regards -- Adrian Hey

On Fri, 2005-01-21 at 07:25 +0000, Adrian Hey wrote:
On Thursday 20 Jan 2005 7:35 pm, Dmitri Pissarenko wrote:
In my program, I need ONLY to read an image and to transform it into such matrix.
Which graphics library can you recommend, if no other image manipulation operations are required?
These might help.. http://homepages.nildram.co.uk/~ahey/HLibs/Multimedia.SDL.Core/ http://homepages.nildram.co.uk/~ahey/HLibs/Multimedia.SDL.Image/
What you'll get is an SDL surface (C data structure), so you'll have to write some code to read it if you want a Haskell array.
We have a similar binding to Gdk's pixmap features in gtk2hs. I was thinking it would probably not be too hard to provide an instance of MArray for these bitmap C structures. That'd make it much easier to use and if we can do it right should be zero-copy (ie quick). Duncan
participants (5)
-
Adrian Hey
-
Dmitri Pissarenko
-
Duncan Coutts
-
Greg Buchholz
-
Ketil Malde