Training-image patterns (every full template window) are reduced to six
directional filter scores (average 1 - abs(u)/m, gradient u/m, curvature
2 abs(u)/m - 1 along x and y), classified by k-means (k-means++ seeding)
on standardised scores, and their class means become prototypes. Along a
random path the data event is matched to the closest prototype and the
inner patch of a pattern drawn from that class is pasted onto uninformed
nodes; hard data are honoured. Philox draws; identical to the Python arm
morie.fn.filtersim (coordinates 0-based in hard_data).
Usage
FilterSim(
training_image,
nx,
ny,
template = 7L,
inner = NULL,
n_classes = 10L,
hard_data = NULL,
seed = 1,
max_kmeans = 50L
)Arguments
- training_image
Numeric matrix (rows y, columns x).
- nx, ny
Simulation grid size.
- template
Odd template width.
- inner
Half-width of the pasted patch (default template %/% 4).
- n_classes
Number of k-means classes.
- hard_data
Optional matrix with columns x, y (0-based) and value.
- seed
Philox seed.
- max_kmeans
Maximum Lloyd iterations.
Value
List: realisation (ny by nx matrix), n_patterns, class_sizes, prototypes, classes_used (0-based).
References
Zhang, T., Switzer, P. and Journel, A. (2006). Filter-based classification of training image patterns for spatial simulation. Mathematical Geology 38, 63-80.
Examples
ti <- outer(1:24, 0:23, function(y, x) as.numeric((x %/% 3) %% 2 == 0))
FilterSim(ti, 12, 6, template = 5, n_classes = 4, seed = 2)$realisation[1, ]
#> [1] 1 0 0 0 1 1 1 0 0 0 0 1
