If no palette is given, automatically extract it. Could/should we output the palette along side the map? Should we store it somewhere for future use?