Page 1 of 1

pixel to file

Posted: 2014-01-10T13:25:59-07:00
by Elmit
It is not an IM question, but I hope that somebody can give me a hint where to start.

I have to create a file for a machine, which is an "image" of 240 x 32 pixels.
The machine reads the pixels in columns from top to bottom
(For this I think to turn a picture by 90 degree and flip it, then the pixel order left to right and top to bottom will be converted to top to bottom and left to right)

The pixel has only 3 bits !!! for RGB (000, 001, 010, 011, 100, 101, 110, 111)

The resulting file includes ONLY the pixels (binary).

I need to create/display this file on a web page first and then convert it to the above structure.

Which image format would be closest to that task? (bmp ?)

I looked at the bmp description and wonder if I could just cut off the headers.
How can I convert the color depth to only one value of RGB?

Re: pixel to file

Posted: 2014-01-10T14:23:36-07:00
by snibgo
Elmit wrote:How can I convert the color depth to only one value of RGB?
You can do that in IM:

Code: Select all

convert in.png -posterize 2 out.png

Re: pixel to file

Posted: 2014-01-10T17:25:24-07:00
by glennrp

Code: Select all

convert rose: -depth 1 -compress none rose.ppm
Then use your text editor to change all of the 255's to 1 and remove the header.

Re: pixel to file

Posted: 2014-01-10T17:47:31-07:00
by snibgo
glenrp wrote:convert rose: -depth 1 -compress none rose.ppm
Brilliant. Why didn't I think of that? I'll get the hang of IM one day ...