jit.charmap with float32 matrix support?
Hi!
I'm looking for a way to make the 'jit.charmap' object support 32bit matrixes.

Let me explain why:
For the project 'Lightkeeping' I made some sort of digital camera. It's really a laser ranger on a pan-tilt head that scans all positions in a 1920x1080 grid.
This is the camera, with a rain cover
After a few days (or a few weeks, depending on the maximum distance) I end up with a csv-textfile:
- X-position, Y-position, distance in centimeter
- I put the distance measurements in a coll, dump them in a matrix (float32) and normalise everything in the 0.-1. range
- With jit.expr, I generate a one dimensional matrix, so I end up with a gradient going from black to white, which I can easily adjust.
- with jit.charmap I combine the distance matrix (stepped down to char) and the one dimensional gradient matrix. By changing the gradient I'm able to virtually light up different portions of the space.
- This is all cool, but the limitation of the char matrix creates banding. Sometimes pretty severe. Stepping up to a float32 matrix system would solve this.
I'm looking into the cc.colormap.jxs example (/examples/jitter-examples/render/slab-helpers/color/cc.colormap.jxs-help.maxpat) but I have a hard time wrapping my head around it. Also, I want a pixel-perfect pipeline. And I'm not sure if that happens when going back and forth to open GL and matrixes.
Attached are two images:
- one is smooth (rendered with a different method than jit.charmap)
- and one is posterized (rendered with jit.charmap).
I would like to use the charmap approach since it allows for more freedom in making different gradients and animating them
Elias Heuninck
maybe an input to output LUT / transfer function with a float resolution is just too big?
> I guess so: float32 precision equals 4294967296 possible values. It's not possible to make a 1 dimensional matrix this wide.
Is it possible to calculate a result on the fly, rather than using a LUT? Would that be doable performance wise?
In this method, every pixel is fed into a function that draws a curve (created and animated with GUI parameters) where the distance acts as a pointer on the X-axis. The Y value of the graph is then output to the new matrix.

block diagram of how it could work. This is similar to the Charmap object, apart from the higher float32 precision that I'd like to have.

the graph generates 'virtual' lighting for the depth-map image
I don't know about max/msp objects that can generate a gradient / graph without a matrix. Do these exist?
Elias Heuninck
there's jit.expr, if you are comfortable with using equations to generate curves, or you could use the function object which will interpolate for you, but it only works on single values so you need to spill into a list and then iterate, then pack back into a matrix (may not be efficient enough for you):
(someone will probably know of a better way than this)
Hi Floating point,
Interesting way to use jit.spill and iterate through the list.
Probably not the most efficient way to work, but it opens new possibilities!
here's a more efficient method using jit.expr:
it does pretty much what the previous patch does (remap floats within 0-1), but using an expression instead of a GUI-determined curve