Julia implementation of indexed or "lookup" arrays
Clone or download
timholy Merge pull request #17 from JuliaArrays/teh/travis
Update CI scripts for 0.7/1.0
Latest commit 6dcf489 Aug 11, 2018



Build Status


An IndirectArray is one that encodes data using a combination of an index and a value table. Each element is assigned its own index, which is used to retrieve the value from the value table. Concretely, if A is an IndirectArray, then A[i,j...] = value[index[i,j,...]].

Among other uses, IndirectArrays can represent indexed images, sometimes called "colormap images" or "paletted images."




For example:

using IndirectArrays, Colors

colors = distinguishable_colors(6)
index = rand(1:6, 32, 32)
A = IndirectArray(index, colors)

random image

which has only 6 colors in it.

The value array can be of any type; it does not have to be color information.

Note that setindex! is not supported: you cannot set the value of A to an arbitrary value, because the value has to be one of the values in the value table.

Related packages

  • CategoricalArrays offers an even more flexible interface for dealing with arrays in which values are looked up in an index.
  • PooledArrays supports setindex!, but requires that values be sorted.