load image bitmap into array

S

Snaggy

I'm trying to load a grayscale image (some standard format will do,
jpeg, png, bmp etc..) into an array, where I can access every pixel by
its coohrdinates and where every pixel is described by a single number
(0..255 8bit) from white to black.

How can I do that? I only need to read, not write images. It's for
analysing them..

thanks
Luca
 
T

Tim Hunter

Snaggy said:
I'm trying to load a grayscale image (some standard format will do,
jpeg, png, bmp etc..) into an array, where I can access every pixel by
its coohrdinates and where every pixel is described by a single number
(0..255 8bit) from white to black.

How can I do that? I only need to read, not write images. It's for
analysing them..

You can do that with RMagick's Image#view.

However, the quantum range will depend on how ImageMagick is configured.
If you require 0-255 then you'll need to make sure to install
ImageMagick configured with --quantum-depth=8. Most of the pre-built
ImageMagick packages that you get with Ubuntu or RedHat are built with
--quantum-depth=16 so the quantum range is 0-65535.

Image#view doc here:
http://studio.imagemagick.org/RMagick/doc/image3.html#view
--with-quantum-depth info here:
http://www.imagemagick.org/script/advanced-unix-installation.php#linux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top