qgis – Extracting Pixels from Raster Based on Tolerance Value Similar to Photoshop

extractqgisraster

I'm new with raster in QGIS. I have a three-band (RGB) georeferenced raster similar to this: (Reference)

enter image description here

And I would like to extract the pixels with similar color like in the following image by given a tolerance value as in Photoshop. In Photoshop, you can change color range to be selected using tolerance value. Two different results depending on the value 32 and 70 are seen in the two images below. (In both images, the darker blue area was clicked by "The Magic Wand Tool")

enter image description here

enter image description here

I was only able to find the following two posts that are most relevant to this topic. But they don't meet my need.

  1. Extracting GeoTIFF colours and adding to equal geometry shapefile
  2. Extracting shapefile attributes from raster colors using PyQGIS?

So, how can I extract the pixels using a color tolerance, as in Photoshop? It doesn't have to be a tolerance value, my ultimate goal is to extract pixels of similar color, but, somehow, I need to be able to set the similarity.

Best Answer

There is the Magic Wand plugin in QGIS that works similar to the magic wand tool known from graphic software. Install the plugin, then simply click on the map canvas and the plugin creates a polygon layer with the selection.

You could use this polygon to rasterize and use the Raster Calculator to mask the colors in the initial raster - or simply use the polygon layer for that.

You can change the Accuracy (Fast to Precise) and Color Threshold (Ambiguous to Strict).

One single click on the Ottoman Empire was enough to create Polygon styled in red hachures: C:\Users\DU\Desktop\temp_new\320.tif

Related Question