ColorTools - Maple Programming Help

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

ColorTools

 ColorsFromImage
 extract the colors from an image

 Calling Sequence ColorsFromImage(filename)

Parameters

 filename - the name of a file, as a string

Options

 • space : string; the color space of the returned colors
 • number : posint; limit on how many colors to process

Description

 • This command extracts the colors from an image file into a list of Color objects.

Examples

 > $\mathrm{with}\left(\mathrm{ColorTools}\right):$
 > $\mathrm{imgfile}≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/images/rollercoaster.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)$
 ${805}$ (5.1)
 > ${\mathrm{full}}_{700..725}$
 $\left[{⟨}\colorbox[rgb]{0.588235294117647,0.666666666666667,0.815686274509804}{RGB : 0.59 0.666 0.815}{⟩}{,}{⟨}\colorbox[rgb]{0.219607843137255,0.254901960784314,0.556862745098039}{{RGB : 0.218 0.255 0.555}}{⟩}{,}{⟨}\colorbox[rgb]{0.125490196078431,0.113725490196078,0.125490196078431}{{RGB : 0.127 0.113 0.125}}{⟩}{,}{⟨}\colorbox[rgb]{0.266666666666667,0.282352941176471,0.32156862745098}{{RGB : 0.269 0.281 0.322}}{⟩}{,}{⟨}\colorbox[rgb]{0.482352941176471,0.533333333333333,0.623529411764706}{RGB : 0.48 0.535 0.623}{⟩}{,}{⟨}\colorbox[rgb]{0.619607843137255,0.698039215686274,0.827450980392157}{RGB : 0.619 0.698 0.828}{⟩}{,}{⟨}\colorbox[rgb]{0.615686274509804,0.694117647058824,0.823529411764706}{RGB : 0.614 0.692 0.825}{⟩}{,}{⟨}\colorbox[rgb]{0.254901960784314,0.301960784313725,0.623529411764706}{{RGB : 0.254 0.3 0.624}}{⟩}{,}{⟨}\colorbox[rgb]{0.447058823529412,0.509803921568627,0.654901960784314}{RGB : 0.447 0.51 0.656}{⟩}{,}{⟨}\colorbox[rgb]{0.611764705882353,0.690196078431373,0.819607843137255}{RGB : 0.611 0.69 0.819}{⟩}{,}{⟨}\colorbox[rgb]{0.52156862745098,0.533333333333333,0.552941176470588}{RGB : 0.522 0.535 0.553}{⟩}{,}{⟨}\colorbox[rgb]{0.258823529411765,0.207843137254902,0.227450980392157}{{RGB : 0.258 0.209 0.228}}{⟩}{,}{⟨}\colorbox[rgb]{0.435294117647059,0.43921568627451,0.490196078431373}{RGB : 0.435 0.44 0.492}{⟩}{,}{⟨}\colorbox[rgb]{0.549019607843137,0.458823529411765,0.192156862745098}{RGB : 0.551 0.457 0.192}{⟩}{,}{⟨}\colorbox[rgb]{0.56078431372549,0.607843137254902,0.698039215686274}{RGB : 0.56 0.609 0.698}{⟩}{,}{⟨}\colorbox[rgb]{0.47843137254902,0.419607843137255,0.392156862745098}{RGB : 0.477 0.42 0.394}{⟩}{,}{⟨}\colorbox[rgb]{0.443137254901961,0.301960784313725,0.176470588235294}{{RGB : 0.443 0.3 0.176}}{⟩}{,}{⟨}\colorbox[rgb]{0.305882352941176,0.341176470588235,0.537254901960784}{{RGB : 0.308 0.341 0.536}}{⟩}{,}{⟨}\colorbox[rgb]{0.32156862745098,0.207843137254902,0.235294117647059}{{RGB : 0.322 0.209 0.235}}{⟩}{,}{⟨}\colorbox[rgb]{0.4,0.337254901960784,0.294117647058824}{{RGB : 0.401 0.335 0.294}}{⟩}{,}{⟨}\colorbox[rgb]{0.592156862745098,0.670588235294118,0.792156862745098}{RGB : 0.594 0.669 0.794}{⟩}{,}{⟨}\colorbox[rgb]{0.6,0.67843137254902,0.807843137254902}{RGB : 0.599 0.677 0.807}{⟩}{,}{⟨}\colorbox[rgb]{0.603921568627451,0.682352941176471,0.811764705882353}{RGB : 0.602 0.681 0.81}{⟩}{,}{⟨}\colorbox[rgb]{0.580392156862745,0.658823529411765,0.807843137254902}{RGB : 0.58 0.657 0.806}{⟩}{,}{⟨}\colorbox[rgb]{0.215686274509804,0.254901960784314,0.549019607843137}{{RGB : 0.217 0.257 0.549}}{⟩}{,}{⟨}\colorbox[rgb]{0.329411764705882,0.345098039215686,0.384313725490196}{{RGB : 0.33 0.346 0.384}}{⟩}\right]$ (5.2)
 > 

Compatibility

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