ColorTools - Maple Programming Help

Home : Support : Online Help : Graphics : Packages : ColorTools : ColorTools/ReducePalette

ColorTools

 ReducePalette
 reduce a large list of colors to a smaller, representative list

 Calling Sequence ReducePalette(colors)

Parameters

 colors - a list of Color objects

Description

 • This command reduces a large list of colors down to a small representative list of less than 20 colors.

Examples

 > $\mathrm{with}\left(\mathrm{ColorTools}\right):$
 > $\mathrm{full}≔\left[\mathrm{seq}\left(\mathrm{Color}\left("RGB",\left[1-i,i,1-i\right]\right),i=0..1,0.05\right)\right]$
 ${\mathrm{full}}{≔}\left[{⟨}\colorbox[rgb]{1,0,1}{RGB : 1 0 1}{⟩}{,}{⟨}\colorbox[rgb]{0.949019607843137,0.0509803921568627,0.949019607843137}{RGB : 0.95 0.05 0.95}{⟩}{,}{⟨}\colorbox[rgb]{0.901960784313726,0.101960784313725,0.901960784313726}{RGB : 0.9 0.1 0.9}{⟩}{,}{⟨}\colorbox[rgb]{0.850980392156863,0.149019607843137,0.850980392156863}{RGB : 0.85 0.15 0.85}{⟩}{,}{⟨}\colorbox[rgb]{0.8,0.2,0.8}{RGB : 0.8 0.2 0.8}{⟩}{,}{⟨}\colorbox[rgb]{0.749019607843137,0.250980392156863,0.749019607843137}{RGB : 0.75 0.25 0.75}{⟩}{,}{⟨}\colorbox[rgb]{0.701960784313725,0.301960784313725,0.701960784313725}{RGB : 0.7 0.3 0.7}{⟩}{,}{⟨}\colorbox[rgb]{0.650980392156863,0.349019607843137,0.650980392156863}{RGB : 0.65 0.35 0.65}{⟩}{,}{⟨}\colorbox[rgb]{0.6,0.4,0.6}{RGB : 0.6 0.4 0.6}{⟩}{,}{⟨}\colorbox[rgb]{0.549019607843137,0.450980392156863,0.549019607843137}{RGB : 0.55 0.45 0.55}{⟩}{,}{⟨}\colorbox[rgb]{0.501960784313725,0.501960784313725,0.501960784313725}{RGB : 0.5 0.5 0.5}{⟩}{,}{⟨}\colorbox[rgb]{0.450980392156863,0.549019607843137,0.450980392156863}{RGB : 0.45 0.55 0.45}{⟩}{,}{⟨}\colorbox[rgb]{0.4,0.6,0.4}{RGB : 0.4 0.6 0.4}{⟩}{,}{⟨}\colorbox[rgb]{0.349019607843137,0.650980392156863,0.349019607843137}{RGB : 0.35 0.65 0.35}{⟩}{,}{⟨}\colorbox[rgb]{0.301960784313725,0.701960784313725,0.301960784313725}{RGB : 0.3 0.7 0.3}{⟩}{,}{⟨}\colorbox[rgb]{0.250980392156863,0.749019607843137,0.250980392156863}{RGB : 0.25 0.75 0.25}{⟩}{,}{⟨}\colorbox[rgb]{0.2,0.8,0.2}{RGB : 0.2 0.8 0.2}{⟩}{,}{⟨}\colorbox[rgb]{0.149019607843137,0.850980392156863,0.149019607843137}{RGB : 0.15 0.85 0.15}{⟩}{,}{⟨}\colorbox[rgb]{0.101960784313725,0.901960784313726,0.101960784313725}{RGB : 0.1 0.9 0.1}{⟩}{,}{⟨}\colorbox[rgb]{0.0509803921568627,0.949019607843137,0.0509803921568627}{RGB : 0.05 0.95 0.05}{⟩}{,}{⟨}\colorbox[rgb]{0,1,0}{RGB : 0 1 0}{⟩}\right]$ (4.1)
 > $\mathrm{numelems}\left(\mathrm{full}\right)$
 ${21}$ (4.2)
 > $\mathrm{reduced}≔\mathrm{ReducePalette}\left(\mathrm{full}\right)$
 ${\mathrm{reduced}}{≔}\left[{⟨}\colorbox[rgb]{0.129411764705882,0.898039215686275,0.125490196078431}{Lab : 80 -77.2 73.1}{⟩}{,}{⟨}\colorbox[rgb]{0.776470588235294,0.235294117647059,0.776470588235294}{Lab : 51 69.4 -43.8}{⟩}{,}{⟨}\colorbox[rgb]{0.305882352941176,0.698039215686274,0.301960784313725}{Lab : 65.1 -49.7 42.5}{⟩}{,}{⟨}\colorbox[rgb]{0.6,0.403921568627451,0.6}{Lab : 50.4 28.9 -19.2}{⟩}{,}{⟨}\colorbox[rgb]{0.454901960784314,0.549019607843137,0.450980392156863}{Lab : 55.9 -14 10.7}{⟩}\right]$ (4.3)
 > $\mathrm{numelems}\left(\mathrm{reduced}\right)$
 ${5}$ (4.4)
 > $\mathrm{imgfile}≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/images/antennas.jpg"\right):$
 > $\mathrm{ImageTools}:-\mathrm{Embed}\left(\mathrm{ImageTools}:-\mathrm{Read}\left(\mathrm{imgfile}\right)\right)$

 > $\mathrm{full}≔\mathrm{ColorsFromImage}\left(\mathrm{imgfile}\right):$
 > $\mathrm{numelems}\left(\mathrm{full}\right)$
 ${1225}$ (4.5)
 > $\mathrm{reduced}≔\mathrm{ReducePalette}\left(\mathrm{full}\right)$
 ${\mathrm{reduced}}{≔}\left[{⟨}\colorbox[rgb]{0.443137254901961,0.403921568627451,0.317647058823529}{Lab : 43.9 0.311 13.6}{⟩}{,}{⟨}\colorbox[rgb]{0.596078431372549,0.541176470588235,0.427450980392157}{Lab : 58.1 0.212 17.5}{⟩}{,}{⟨}\colorbox[rgb]{0.325490196078431,0.298039215686275,0.243137254901961}{{Lab : 32.5 0.717 9.18}}{⟩}{,}{⟨}\colorbox[rgb]{0.509803921568627,0.545098039215686,0.572549019607843}{Lab : 57.3 -1.57 -5.13}{⟩}{,}{⟨}\colorbox[rgb]{0.67843137254902,0.662745098039216,0.607843137254902}{Lab : 69.3 -1.38 8}{⟩}{,}{⟨}\colorbox[rgb]{0.72156862745098,0.733333333333333,0.733333333333333}{Lab : 75.7 -1 -0.58}{⟩}{,}{⟨}\colorbox[rgb]{0.866666666666667,0.858823529411765,0.815686274509804}{Lab : 87.3 -1.02 5.48}{⟩}\right]$ (4.6)
 > $\mathrm{numelems}\left(\mathrm{reduced}\right)$
 ${7}$ (4.7)
 > 

Compatibility

 • The ColorTools[ReducePalette] command was introduced in Maple 18.