# Reduce HaldCLUT png from 12 to 8 level

Does any one know of a way to take an 12 level HaldCLUT png and reduce it to an 8 level png?

Is it purely interpolated, can I go through the image and pick out every int(12/8)-th value while respecting the 12x12x12 boundaries?

This is not a question about HaldCLUT compression, that is a separate thing that I get how that works.

A HALDclut of any size can be converted to any other size by:

1. Create an identity HALDclut of the required size.

2. Apply the old clut.

3. The result is what you need.

For example, with ImageMagick v7:

``magick hald:8 old-clut.png -hald-clut new_clut.png``

I expect the same can be done with GâMIC, but I donât know how.

4 Likes

Thatâs not the best way to do it, in case you want to downscale a CLUT, because it is equivalent to use the ânearest-neighborâ interpolation to the 3D CLUT cube for downsizing.
Moreover, you cannot easily generate a `.png` haldclut for a 8x8x8 or a 12x12x12 CLUT.
What you really want is using an averaged interpolation instead (because you want downsizing), which means you want to average neighboring colors in the 3D CLUT when decreasing the resolution.

I donât know if ImageMagick is able to do that (not sure it does interpolation of 3D images).
With GâMIC, it can be done with something like:

``````\$ gmic input_cube clut12x12x12.cube resize3dx 8 output_cube clut8x8x8.cube
``````
1 Like

The ImageMagick â-hald-clutâ operation changes each pixel in an image by looking up the colour in the HALDclut image, which is conceptually 3D. It does a 3D interpolation, not a simple nearest-neighbour, to calculate each output pixel. Hence I donât think there is a lack of precision with the method I showed. (But it would take more time than I have today to demonstrate this.)

ImageMagick doesnât have GâMICâs powerful ability to manipulate (including resizing) general 3D images.

There may be some confusion over terminology. In ImageMagick, the level of a HALD clut is the square root of the length of each side of the cube. For example, HALD:8 is a cube with 64x64x64 = 262144 entries, and HALD:12 has 2985984 entries.

ImageMagick canât create HALDcluts of 8x8x8 or 12x12x12. The smallest sizes are 4x4x4, 9x9x9, 16x6x16, 25x25x25, and so on.

A more general clut wouldnât need to be a cube, eg it might have 5x13x7 entries. ImageMagick canât process those.

This is excellent, almost exactly what i was looking for. However is it possible in GâMIC to take an png haldclut in as an input and output it as a cube. Either as a straight through or a shrinking it as it goes.