I have a square array with brightness data (Gaussian for this example). I convert it into a grayscale image with Image[]. But I would like to add color via ColorFunction which is why I rasterize it, but not only does that change the image size, it also changes the effective resolution and leads to some artifacts. Here is my code:
data = Table[
Exp[-1/100 ((ix - 50)^2 + (iy - 50)^2)], {ix, 1, 100}, {iy, 1, 100}];
Export["img1.png", Image[data]];
Export["img2.png",
Graphics[Raster[data, ColorFunction -> "SolarColors"],
PlotRangePadding -> 0, ImagePadding -> 0, ImageSize -> 100]];
The two images are attached below (left: original grayscale, right: colorfunction'ed one). Not only does the processed image (img2.png) have a different resolution of 134x134, it seems to me that it also sufferend some compression artifacts.
How can I make sure the image quality in the processed image does not suffer?


dataColored = Map[colorFunc, data, {2}];and thenImage[dataColored]does the trick. But I still don't know why the image generated with Raster has the wrong resolution. $\endgroup$GraphictoExport, so it is being re-rasterized. AndImageSizeis not in pixels, it is in points. $\endgroup$Exportlevel? $\endgroup$