# Partitioning Using Spatial Entropy

In a previous article, I introduced an efficient way to calculate spatial entropy, which is otherwise difficult to calculate (as far as I can tell). The main reason I use spatial entropy is to partition images, and so you can use this method to do exactly that, or more generally partition a space, by simply calculating the spatial entropy of your dataset first (just use method from my previous article, code below), which will be some value $H$. Then, simply take the inverse log of $H$, and take the floor or ceiling of that value. Note that the code I’ve attached automatically returns an integer value.  You can then use this number as the number of regions you partition your space into. So for example, if $K = log^{-1}(H)$, then you would partition the space in question into $K$ equally sized regions, which would require $K^{1/N}$ regions per dimension, where $N$ is the dimension of the space in question.