Log transformation (in dimensions) of an image

Is there an easy way to do a log-transformation of an image? I'm not taking about the colours, but the geometry. The difficulty is to extrapolate pixels and round-offs.

For example, an white image with horizontal dots whose $x$-coordinates follow a power law would be transformed to a white image with regularly spaced dots.

• There was a related question: How does one set a logarithmic scale in a ContourPlot?. I guess this is a duplicate, otherwise you should explain more clearly your expectations. Moreover you should take a closer look at the logarithmic-scale tag. – Artes Sep 14 '15 at 0:49
• The difference is that an imported image is not the same type as a plot: that are pixels instead of numbers. I tried the code to make sure and I get an error ListLogLogPlot called with 0 arguments; 1 argument is expected. – anderstood Sep 14 '15 at 0:55
• I'm afraid that it is very unclear to me what you want to accomplish, especially when you mention "the geometry". Could you be more specific, and possibly provide an example? – MarcoB Sep 14 '15 at 2:07
• @MarcoB I insist on geometry, in contrast to colour, because it is more natural to think of log as an application over the pixels (resulting in a change of contrast). Here, I would like to distort the image in such a way that points near the left end would be moved to the left, and the more a point is initially on the right, the more it is move to the left (log transformation). I understand it might not be very clear. Unfortunately, I don't see how I can give an example as it is exactly what I am trying to do. I'll think about it and try to find a reformulation with illustration if possible. – anderstood Sep 14 '15 at 2:12
• ImageTransformation and ImageForwardTransformation are probably what you're looking for. – shrx Sep 14 '15 at 8:26

You can achieve the desired transformation with the ImageForwardTransformation function. The transformation effect is easily visible on a grid image:

grid = Rasterize[
Graphics[Rectangle[],
GridLines -> {Range[.05, .95, .05], Range[.05, .95, .05]},
GridLinesStyle -> Directive[{White, Thick}],
Method -> {"GridLinesInFront" -> True}, PlotRangePadding -> 0,
ImageSize -> 300]]


You can do the transformation on both dimensions

ImageResize[
ImageForwardTransformation[grid, Log[# + 0.1] &, PlotRange -> All],
ImageDimensions[grid]]


or just on one (x in this example):

ImageResize[
ImageForwardTransformation[grid, {Log[#[[1]] + 0.1], #[[2]]} &,
PlotRange -> All], ImageDimensions[grid]]


Unfortunately, you can't explicitly set the Method used in the interpolation of the transformed image by choosing an option from the Resampling documentation. You can only switch between the Automatic method or None.

• When you know the inverse function, it's better to use ImageTransformation since then you benefit from good interpolation, etc. Like that: ImageTransformation[grid, InverseFunction[Log[# + 0.1] &], ImageDimensions[grid], PlotRange -> All] – Matthias Odisio Sep 23 '15 at 0:52