# Select by raster colour in ArcMap

Is it possible to select every pixel with a certain RGB combination in ArcMap 10.5? For example, from a .tif image I want to select and extract all the red pixels. In this case the RGB codes would be: 251, 118, 121. Is it possible to select these pixels and possibly also expand the range, so that pixels that are slightly darker or lighter would also be selected. Is this at all possible in ArcMap or do I have to use Photoshop (or something similar)?

There are several ways to do that in ArcMap. The first choice from the top of my head would be to use the `raster calculator` with three conditional `Con` statements. I think that this is the best choice to understand what happens under the hood of more automatic algorithms (including the ones in Photoshop).

For example, in the `raster calculator` tool you can create a binary raster with pixel values

• 1 for red = 251
• 0 for red <> 251 (unequal)

Con("red", 1, 0, "Value=251")

Then you can do the same for the green and blue channels.

``````Con("green", 1, 0, "Value=118")
Con("blue", 1, 0, "Value=121")
``````

Multiplying all these three intermediate results returns a pixel with values

• 1 when all the conditions are satisfied
• 0 if any condition was not satisfied.

You can do that on the fly, like so:

``````Con("red", 1, 0, "Value=251") * Con("green", 1, 0, "Value=118") * Con("blue", 1, 0, "Value=121")
``````

The above returns a raster with values

• 1 for the exact RGB values of 251, 118, 121
• 0 for all the rest

Similarly you can combine statements for a range of values in each color band by using greater and lower than operators.

For example, to get all red values above 251, the green values greater than 100 and lower than or equal to 125, the blue values greater than 120 and lower than or equal to 135, you would want to combine all these partial evaluations:

``````Con("red", 1, 0, "Value>251")
Con("green", 1, 0, "Value>100")
Con("green", 1, 0, "Value<=125")
Con("blue", 1, 0, "Value>120")
Con("blue", 1, 0, "Value<=135")
``````

In the `raster calculator` you can multiply on the fly these partial rasters and directly get the result:

``````Con("red", 1, 0, "Value>251") * Con("green", 1, 0, "Value>100") * Con("green", 1, 0, "Value<=125") * Con("blue", 1, 0, "Value>120") * Con("blue", 1, 0, "Value<=135")
``````
• Is there a way to do this without the Spatial Analyst extension? Mar 11, 2020 at 10:10