Computationally Efficient Ways of Determining If Pixels Are Clumped
I've not tried this, but I'm wondering if something like a simple low pass filtering, followed by a column sum will do.

No time to explain code right now, but this seems to do something like what you want. Will return in a few hours and explain what it's doing.







R Code Below

library(imager)

N &lt;- 128

noise &lt;- array(runif(N*N*1*1),c(N,N,1,1)) #5x5 pixels, 1 frames, 1 colours. All noise
small_clumps &lt;- as.cimg(noise)
blurry &lt;- isoblur(small_clumps,5)

layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE))
plot(colSums(blurry-mean(blurry)))
plot(small_clumps)
plot(blurry)


large_clumps &lt;- small_clumps
large_clumps[65:75, 65:75] &lt;- 1
large_clumps[15:25, 35:45] &lt;- 1
blurry_large &lt;- isoblur(large_clumps,5)
# par(mfrow=c(3,1))
layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE))
plot(colSums(blurry_large-mean(blurry_large)))
plot(large_clumps)
plot(blurry_large)