I have decided to make my own version of colormap, and I would like to know if the output is indeed correct. So, update G’MIC to test it.
Same parameters is used by my version rep_colormap. colormap 0 and rep_colormap 0 both have matching statistics, despite that they both have very different algorithm. For finding all colors, rep_colormap use 2 steps dictionary processing as to allow parallelization.
There are some numerical difference when using restricted color count, but I suspect that has to do with rep_colormap using doubles instead of float32, but I am not entirely sure of this. I do however notice that rep_colormap is faster.
You can see the output here:
C:\Windows\System32>gmic sp cat +rep_colormap 5,1,0
[gmic]./ Start G'MIC interpreter (v.3.7.0).
[gmic]./ Input sample image 'cat' (1 image 600x550x1x3).
[gmic]./ Estimate colormap with 5 entries for image [0], by k-means method.
[gmic]./ Display images [0,1] = 'cat, cat_c2'.
[0] = 'cat':
size = (600,550,1,3) [3867.2 Kio of float32].
data = (202,212,212,219,219,219,219,219,219,219,219,219,219,219,219,219,219,219,212,219,212,212,212,212,212,212,212,212,212,202,202,202,202,202,202,202,212,212,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,193,193,193,193,193,193,193,188,188,188, ... ,140,128,95,95,79,80,70,81,89,95,117,115,95,70,62,70,70,51,46,45,79,99,117,128,133,128,117,59,16,19,70,80,81,89,99,79,70,79,81,115,128,128,95,59,79,106,117,117,128,128,79,79,95,103,103,95,70,79,128,147,146,117,59,13).
min = 4, max = 244, mean = 113.418, std = 66.7981, coords_min = (293,0,0,0), coords_max = (144,29,0,0).
[1] = 'cat_c2':
size = (5,1,1,3) [60 b of float32].
data = (79.0526,206.922,201.203,139.304,157.566^41.3372,125.527,180.642,89.791,120.956^16.352,45.7982,156.722,40.2507,78.4207).
min = 16.352, max = 206.922, mean = 111.99, std = 59.522, coords_min = (0,0,0,2), coords_max = (1,0,0,0).
[gmic]./ End G'MIC interpreter.
C:\Windows\System32>gmic sp cat +colormap 5,1,0
[gmic]./ Start G'MIC interpreter (v.3.7.0).
[gmic]./ Input sample image 'cat' (1 image 600x550x1x3).
[gmic]./ Estimate colormap with 5 entries for image [0], by k-means method.
[gmic]./ Display images [0,1] = 'cat, [colormap of cat]_c1'.
[0] = 'cat':
size = (600,550,1,3) [3867.2 Kio of float32].
data = (202,212,212,219,219,219,219,219,219,219,219,219,219,219,219,219,219,219,212,219,212,212,212,212,212,212,212,212,212,202,202,202,202,202,202,202,212,212,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,193,193,193,193,193,193,193,188,188,188, ... ,140,128,95,95,79,80,70,81,89,95,117,115,95,70,62,70,70,51,46,45,79,99,117,128,133,128,117,59,16,19,70,80,81,89,99,79,70,79,81,115,128,128,95,59,79,106,117,117,128,128,79,79,95,103,103,95,70,79,128,147,146,117,59,13).
min = 4, max = 244, mean = 113.418, std = 66.7981, coords_min = (293,0,0,0), coords_max = (144,29,0,0).
[1] = '[colormap of cat]_c1':
size = (5,1,1,3) [60 b of float32].
data = (67.3609,178.684,206.229,150.732,195.195^27.9121,108.59,186.261,56.9209,150.91^12.7823,44.1835,160.4,14.5111,94.8767).
min = 12.7823, max = 206.229, mean = 110.37, std = 67.0463, coords_min = (0,0,0,2), coords_max = (2,0,0,0).
[gmic]./ End G'MIC interpreter.