How to select a particular color in an image using the new Images.jl?



Suppose I give you an image like the Julia logo:

Let’s say I am interested in creating a binary mask that indicates the black letters (i.e. Julia) or that I am interested in selecting only the blueish dot on top of “J”. How do you go in solving this problem? Assume we have the RGB channels of the image in three separate Julia arrays R, G, B. Can we relax this query so that it captures not only a single color like “blue”, but all colors that are “blueish”?


Something like

using Colors

function mask(image, color, cutoff, metric=DE_2000())
    _mask(c) = colordiff(c, color, metric) ≤ cutoff
    map(_mask, image)

but you should be more precise about how you define “similar”. See Colors.colordiff, or transform into some other space (eg HSV?) and define a metric there.