condense_matrix {mazing}R Documentation

Halve the dimensions of a matrix

Description

A function to decrease the size of a matrix while attempting to preserve the original values.

Usage

condense_matrix(m, fun = median)

Arguments

m

A matrix.

fun

A function for summarizing four values that condenses them down to one value. Default is median.

Details

This function can be used for image manipulation and is included for the purpose of making mazes from images. PNG images can be read in as arrays via png::readPNG and if the image is too big, this funtion can help get it down to a more manageable size.

Value

A matrix with dimensions half the size of the original matrix, where each value is a summary of the four corresponding values in the original.

Examples

m <- outer(1:4, 1:6)
condense_matrix(m)


[Package mazing version 1.0.5 Index]