MoransI

Elixir module that implements Moran's I spatial autocorrelation index for images.

Moran's I is a measure of spatial autocorrelation that indicates whether nearby pixels in an image have similar values (positive autocorrelation), dissimilar values (negative autocorrelation), or random spatial distribution.

Values range from -1 to 1:

Installation

The package can be installed by adding moransi to your list of dependencies in mix.exs:

def deps do
  [
    {:moransi, "~> 0.1.1"}
  ]
end

Key Features

$$ Var(I) = \frac{n((n²-3n+3)S1 - nS2 + 3S0²) - b2((n²-n)S1 - 2nS2 + 6S0²)}{(n-1)(n-2)(n-3)S0²} $$

Interpretation

Statistical Significance: Z-scores and p-values help determine if observed patterns are statistically significant.

Cluster Types

Main Functions

Usage

# Basic usage
result = MoransI.global_morans_i(image)

# With options
local_results = MoransI.local_morans_i(image, 
  connectivity: :rook,
  parallel: true,
  chunk_size: 2000
)

# For very large images
huge_image_results = MoransI.local_morans_i(huge_image,
  parallel: true,
  chunk_size: 5000  # Adjust based on available memory
)

How Moran's I Works

Moran's I measures the degree of spatial clustering or dispersion of these attribute values within the point cloud. Computing Moran's I for a point cloud involves assessing the spatial autocorrelation of attribute values associated with each point in the cloud.

Steps to Compute Moran's I for a Point Cloud

$$ I = \frac{n}{\sum{i=1}^{n} \sum{j=1}^{n} w{ij} \cdot \frac{ \sum{i=1}^{n} \sum{j=1}^{n} w{ij} (xi - \bar{x})(x_j - \bar{x}) }{ \sum{i=1}^{n} (x_i - \bar{x})^2 }} $$

where: