7

I am using QGIS 3.16.12 - Hannover. I have a binary raster layer which consists of 2 values, either 0 or 1 (in my screenshots, 0 = black, 1 = white). The 1 values are scattered throughout the layer in various clusters, sometimes they are close together and may form a loose clump of 20 plus pixels, but others may only be a single pixel surrounded by 0s. Please see below image for an example of the layer.


Example of binary raster, black = 0 and white = 1


Is there a way to classify or segment this raster layer, so that I can determine clusters of value = 1 pixels (white) in a given area? For example, let me select all value = 1 (white pixels) that have a sum value of greater than 20 within a radius of 20 pixels of each other. Thereby keeping the clusters, but omitting those pixels that are all out by themselves? Please see example below.


Example of clusters selected


I can use sieve to sift out all the smaller clusters, but this is slightly different to picking clusters greater than 'x' pixels within 'y' area.

0

2 Answers 2

5

You can use GRASS:s i.segment:

enter image description here

enter image description here

0
4

You could use r.neighbors It does exactly what you want to accomplish.

It will look at a surrounding area of n*n pixels around each pixel and give you a selected stat, in your case, the sum of all pixels. From here you will have a density raster where you can identify the pixels exceeding a certain threshold, in your case >20.

It also allows to use a circular neighborhood setting, here is the tool's example of it:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.