1. A method of encoding data, the method comprising: encoding a first portion of an array of data to generate a first set of coefficients, using a first transform; decoding the first set of coefficients to generate a decoded approximation of the first portion, using the first transform; selecting a second transform from multiple candidate transforms based at least in part on a measure of encoding performance for each candidate transform used to encode the decoded approximation of the first portion; and encoding a second portion of the array of data in proximity to the first portion of the array of data to generate a second set of coefficients using the selected second transform.