[Qgis-user] Raster algebra: RGB feature extraction

"Peter Löwe" peter.loewe at gmx.de
Tue Sep 13 10:24:07 PDT 2016


Hi list,

here is a question on how to extract spatial features from a RGB raster with the raster calculator.

Here's the situation:

- I am using QGIS 2.12.3 Lyon
- The goal is to extract a feature from an aerial photo as a binary map (e.g. a winding clearly yellow colored linear feature)
- A RGB-raster was imported from PNG.
- The raster can be properly displayed.
- A object-query on the yellow colored feature gives a RGB value of channel1:255  channel2:255 channel3:0
- A first naive approach was to calculate (("image at 1"=255)AND("image at 2"=255))AND("image at 3"=0). This resulted in a raster of 0s.
- Multiples trials showed that also the calculation of individual raster layers of image at 1=255 ,image at 2=255 and image at 3=0 also result in empty rasters.
- More trial and error showed that individual calculation of image at 1 > 200 , image at 2 > 200 and image at 3 < 30 give reasonable results each. Chaining these binary maps (again) with AND leads yet gain to an empty result.

I have a bit of a GRASS background so probably I'm thinking too much along the lines of r.mapcalc.

Any comments on what I am doing wrong would be much appreciated.

best,
Peter 




More information about the Qgis-user mailing list