We present a simple method for adaptively binning the pixels in an image. T
he algorithm groups pixels into bins of size such that the fractional error
on the photon count in a bin is less than or equal to a threshold value, a
nd the size of the bin is as small as possible. The process is particularly
useful for generating surface brightness and colour maps, with clearly def
ined error maps, from images with a large dynamic range of counts, for exam
ple X-ray images of galaxy clusters. We demonstrate the method in applicati
on to data from Chandra ACIS-S and ACIS-I observations of the Perseus clust
er of galaxies. We use the algorithm to create intensity maps, and colour i
mages that show the relative X-ray intensities in different bands. The colo
ur maps can later be converted, through spectral models, into maps of physi
cal parameters, such as temperature, column density, etc. The adaptive binn
ing algorithm is applicable to a wide range of data, from observations or n
umerical simulations, and is not limited to two-dimensional data.