OpenBI Docs Buy

IMAGECOLOR OpenBI

One colour of a picture at an address or a data: URI, by rank (1: the dominant one), as #RRGGBB.

Group: Images and colours. OpenBI’s own: DAX has no function of this name.

Syntax

IMAGECOLOR ( <image> [, <rank>] [, <count>] [, <skip_white>] [, <skip_black>] [, <white_tolerance>] [, <black_tolerance>] )
ParameterTypeDescription
imageTextThe picture: a data: URI (data:image/png;base64,...), its base64 text alone, or its address on the web (http:// or https://).
rankWhole number
optional
Which colour: 1, when left out, is the one with the most pixels, 2 the next.
countWhole number
optional
How many colours to look for, from 1 to 50; 9 when left out.
skip_whiteBoolean
optional
TRUE, or left out, to leave near-white pixels out; FALSE to count them.
skip_blackBoolean
optional
TRUE, or left out, to leave near-black pixels out; FALSE to count them.
white_toleranceWhole number
optional
How near to white a pixel must be to be left out as white, from 0 to 255; 20 when left out.
black_toleranceWhole number
optional
How near to black a pixel must be to be left out as black, from 0 to 255; 20 when left out.

Returns

Text. The colour at that rank, written #RRGGBB; BLANK when the picture has fewer colours.

Remarks

  • It is the Color of one row of IMAGECOLORS with the same options: IMAGECOLOR ( image, 2 ) is the second row's colour. That page tells how the colours are found.
  • A rank past the colours found gives BLANK; a rank outside 1 to 50, or with a fraction, is an error.
  • A blank or empty image gives BLANK.
  • COLORNAME gives the colour a name.

Compared with DAX

An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.

Examples

The colours of a small picture, by rank

Five fire brick pixels, two gold and one white, which is left out: two colours, so there is no third.

EVALUATE
VAR Picture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAIAAADwyuo0AAAAF0lEQVR42mPYpKQEQf+vMzDAWf///wcAfmYLeNgtE+UAAAAASUVORK5CYII="
RETURN
    ROW (
        "1st", IMAGECOLOR ( Picture ),
        "2nd", IMAGECOLOR ( Picture, 2 ),
        "3rd", IMAGECOLOR ( Picture, 3 )
    )
1st2nd3rd
#B22222#FFD700(blank)

The main colour of each picture in a table

EVALUATE
VAR Pictures =
    DATATABLE (
        "Label", STRING, "Picture", STRING,
        { { "Brick", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAIAAADwyuo0AAAAF0lEQVR42mPYpKQEQf+vMzDAWf///wcAfmYLeNgtE+UAAAAASUVORK5CYII=" },
          { "Night", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAEklEQVR42mNgYGgAI4aG/9cZABA5A1dz4G/yAAAAAElFTkSuQmCC" } }
    )
RETURN
    SELECTCOLUMNS (
        Pictures,
        "Label", [Label],
        "Main colour", IMAGECOLOR ( [Picture] ),
        "Name", COLORNAME ( IMAGECOLOR ( [Picture] ) )
    )
ORDER BY [Label]
LabelMain colourName
Brick#B22222fire brick
Night#000080navy

IMAGECOLORS, COLORNAME, SELECTCOLUMNS.

Last updated · OpenBI Studio 0.3.74