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

**URL:** https://discourse.julialang.org/t/how-to-select-a-particular-color-in-an-image-using-the-new-images-jl/1930
**Category:** Visualization
**Tags:** question, images
**Created:** [February 6, 2017, 1:08am UTC](https://discourse.julialang.org/t/how-to-select-a-particular-color-in-an-image-using-the-new-images-jl/1930 "2017-02-06T01:08:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [February 6, 2017, 1:08am UTC](https://discourse.julialang.org/t/how-to-select-a-particular-color-in-an-image-using-the-new-images-jl/1930/1 "2017-02-06T01:08:13Z")

</div>

Suppose I give you an image like the Julia logo:

![Julia](https://sea2.discourse-cdn.com/julialang/images/transparent.png)

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”?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [February 6, 2017, 7:52am UTC](https://discourse.julialang.org/t/how-to-select-a-particular-color-in-an-image-using-the-new-images-jl/1930/2 "2017-02-06T07:52:26Z")

</div>

Something like

```julia
using Colors

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

```

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.
