1
$\begingroup$

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"):

enter image description here

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!

$\endgroup$
1
$\begingroup$

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]}]]

enter image description here

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"}]

enter image description here

color distribution making use of HistogramTransform:

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

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.