I have a plotter like this one:
The task which I have to implement is conversion of 24 bits BMP to set of instructions for this plotter. In the plotter I can change 16 common colors. The first complexity which I face is the colors reduction. The second complexity which I face is how to transform pixels into set of drawing instructions.
As drawing tool brush with oil paint will be used. It means that plotter drawing lines will not be so tiny and they will be relatively short.
Please suggest algorithms which can be used for solving this image data conversion problem?
Some initial results:
Dithering
Well I got some time for this today so here the result. You did not provide your plotter color palette so I extracted it from your resulting images but you can use any. The idea behind dithering is simple our perception integrates color on area not individual pixels so you have to use some accumulator of color difference of what is rendered and what should be rendered instead and add this to next pixel ...
This way the area have approximately the same color but only discrete number of colors are used in real. The form of how to update this info can differentiate the result branching dithering to many methods. The simple straightforward is this:
Here your input image (I put them together):
Here result image for your source:
The color squares in upper left corner is just palette I used (extracted from your image).
Here code (C++) I do this with:
where
picture
is my image class so here some members:xs,ys
resolutioncolor p[ys][xs]
direct pixel access (32bit pixel format so 8 bit per channel)clear(DWORD c)
fills image with colorc
The
color
is justunion
ofDWORD dd
andBYTE db[4]
for simple channel access.The
List<>
is my template (dynamic array/list>List<int> a
is the same asint a[]
.add(b)
add b to it at the end of listnum
is number of items in listNow to avoid too many dots (for the lifespan of your plotter sake) you can use instead different line patterns etc but that needs a lot of trial/error ... For example you can count how many times a color is used in some area and from that ratio use different filling patterns (based on lines). You need to choose between quality of image and speed of rendering/durability ...
Without more info about your plotter capabilities (speeds, method of tool change,color combination behavior) is hard to decide best method of forming control stream. My bet is you change the colors manually so you will render each colors at once. So extract all pixels with the color of first tool merge adjacent pixels to lines/curves and render ... then move to next tool color ...