slicing grayscale into multiple monochrome bitmaps

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tmalfrere
Posts: 2
Joined: 2017-11-10T02:34:47-07:00
Authentication code: 1152

slicing grayscale into multiple monochrome bitmaps

Post by tmalfrere » 2017-11-10T02:48:27-07:00

Hi,

I have a laser system that works with monochrome bitmaps only (0=laser OFF/ 1=laser ON).

Is it possible to convert a grayscale bitmap (eg. 8bit) in to a set of monochrome (255) bitmaps. This way I could do 255 passes with a different bitmap for each pass.
I want to slice a 8bit grayscale into 256 monochrome bitmaps (or the number of different values present in the greyscale bitmap)

An example:
If the value for a bit in the bitmap is 10, this would result in 10 bitmaps with the bit set to 1 and 245 bitmaps with the value set to 0

Does something like this exist? can you do this with imagemagick

snibgo
Posts: 9406
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: slicing grayscale into multiple monochrome bitmaps

Post by snibgo » 2017-11-10T03:20:08-07:00

I can see how to slice 8-bit values into 8 slices, but not into 256 slices.

How would you calculate what values to put in the 256 bitmaps? Suppose the input image had a value of 200. Would you put "1" in the first 200 bit maps, then "0" in the other 56?
snibgo's IM pages: im.snibgo.com

tmalfrere
Posts: 2
Joined: 2017-11-10T02:34:47-07:00
Authentication code: 1152

Re: slicing grayscale into multiple monochrome bitmaps

Post by tmalfrere » 2017-11-13T06:49:39-07:00

yes, exactly.

Think of it this way:
The value of a pixel in the bitmap is the number of times you shoot on a pixel with your laser.

snibgo
Posts: 9406
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: slicing grayscale into multiple monochrome bitmaps

Post by snibgo » 2017-11-13T07:30:31-07:00

Windows CMD syntax, where in.png is a grayscale image:

Code: Select all

magick in.png -duplicate 255 -threshold %[fx:t*QuantumRange/256] laser-%03d.png
This create outputs laser-000.png, laser-001.png, ... laser-255.png. They all contain pixels that are either black or white. The mean of all all the outputs laser-*.png reproduces in.png.

Depending on your laser device, it might be best if in.png was linear RGB (instead of sRGB), or some other transformation.
snibgo's IM pages: im.snibgo.com

Post Reply