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](https://i.stack.imgur.com/KPEsA.png)](https://i.stack.imgur.com/KPEsA.png)

---

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](https://i.stack.imgur.com/XGADu.png)](https://i.stack.imgur.com/XGADu.png)

---

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.