# How to change color of DistanceTransform image?

I want to overlay a set of points onto a distance transform of them. But I don't really like the black default color of the distance transform. Is there a way to change this?

Given the points pts:

pts = RandomReal[{-1, 1}, {1000, 2}];

We can compute their distance transform image (+ ImageAdjust):

Dpts = DistanceTransform[Graphics[Point[pts]]] // ImageAdjust;

Then, compose this image with the points (say, red points):

ImageCompose[Dpts, Graphics[{RGBColor[0.82, 0., 0.34], Point[pts]}]]

To obtain a nice overlay, but it's not pretty (it's, well, too "dark"):

Can we change the color appearance of the distance transform?

Additionally, can we adjust the image resolution? Zooming in just makes evident that the image is not very high res.

Thanks!

Generally, I really recommend image processing docs - lots useful stuff there:

DistanceTransform resolution depends on your original image resolution which you can control in Graphics:

dpts = ImageAdjust[DistanceTransform[Graphics[Point[pts], ImageSize -> 500]]]


There are many ways to change color schemes. For instance:

Colorize[dpts, ColorFunction -> "Rainbow"];
ImageCompose[%,Graphics[{RGBColor[0.82,0.,0.34],Point[pts]}]]


Available color schemes are listed here:

http://reference.wolfram.com/language/guide/ColorSchemes.html

Another method would be changing colors based on another image

i = ExampleData[{"TestImage", "Apples"}]


color distribution making use of HistogramTransform:

HistogramTransform[ColorConvert[dpts,"RGB"],i];
ImageCompose[%,Graphics[{RGBColor[0.82,0.,0.34],Point[pts]}]]