1

Is it possible to invert an image (the format is png, jpg, bmp) with respect to the given reference circle in LaTeX? Can we transform the individual pixels (e.g. with complex transformations such as Möbius transformation)?

Mathematical inversion is a geometric transformation of the Euclidean plane. In coordinate geometry if the reference circle is the unit circle and P(x,y) is not the origin, then the image of P(x,y) is P'(\frac{x}{x^2+y^2},\frac{y}{x^2+y^2}). In the complex plane if the reference circle is the unit circle and z is not the origin, then its image is z'=\overline{1/z}.

(P.S. How to filter far images of points from the origin?)

  • Welcome! You can't use .bmp anyway, unless you are transforming it. (Certainly won't work here out-of-the-box.) Even if the transformation can/could be done in TeX (it is presumably possible in some abstract sense, provided a digital computer could do it), you will be much better using an external tool. – cfr Jun 10 '17 at 23:11
  • I don't understand the postscript. – cfr Jun 10 '17 at 23:11
  • #cfr If P(x,y) tends to the origin then its image tends to infinity. It is one property of the inversion. Look P'(,) 's denominator! – csekri Jun 10 '17 at 23:15
  • And what about png and jpg? I can convert pictures with external tool (e.g. ffmpeg) so I need only one suitable format. – csekri Jun 10 '17 at 23:33
  • 1
    @csekri: Indeed, I removed my previous comment because, on second thought, I saw that what you are asking for could make some sense; nonetheless, I still deem it crazy! But according to Bernard’s comment, it is not crazy enough to discourage somebody from actually implementing it… :-) – GuM Jun 11 '17 at 0:57
2

Because why not?

\documentclass[border=9,tikz]{standalone}
\begin{document}

\pgfmathdeclarefunction{fx}{2}{\pgfmathparse{25*(#1/10+3)/((#1/10+3)^2+(#2/10+0)^2)}}
\pgfmathdeclarefunction{fy}{2}{\pgfmathparse{25*(#2/10+0)/((#1/10+3)^2+(#2/10+0)^2)}}
\pgfmathdeclarefunction{fxx}{2}{\pgfmathparse{fx(#1+1,#2)-fx(#1,#2)}}
\pgfmathdeclarefunction{fxy}{2}{\pgfmathparse{fy(#1+1,#2)-fy(#1,#2)}}
\pgfmathdeclarefunction{fyx}{2}{\pgfmathparse{fx(#1,#2+1)-fx(#1,#2)}}
\pgfmathdeclarefunction{fyy}{2}{\pgfmathparse{fy(#1,#2+1)-fy(#1,#2)}}

\tikz{
    \path(-6,-5)(13,5);
    \draw circle(.05)circle(5)
        (3,0)node{\includegraphics[width=2cm]{lenna.png}};
    \foreach\i in{-10,...,9}{
        \foreach\j in{-10,...,9}{
            \pgfmathsetmacro\aa{fxx(\i,\j)}
            \pgfmathsetmacro\ab{fxy(\i,\j)}
            \pgfmathsetmacro\ba{fyx(\i,\j)}
            \pgfmathsetmacro\bb{fyy(\i,\j)}
            \pgfmathsetmacro\xx{fx (\i,\j)}
            \pgfmathsetmacro\yy{fy (\i,\j)}
            \pgflowlevelobj{
                \pgfsettransformentries{\aa}{\ab}{\ba}{\bb}{\xx cm}{\yy cm}
            }{
                \fill[black!10](1,0)--(0,0)--(0,1);
                \clip(1,0)--(0,0)--(0,1)--cycle;
                \tikzset{shift={(-\i,-\j)}}
                \path(0,0)node{\includegraphics[width=20cm]{lenna.png}};
            }
            \pgfmathsetmacro\aa{fxx(\i  ,\j+1)}
            \pgfmathsetmacro\ab{fxy(\i  ,\j+1)}
            \pgfmathsetmacro\ba{fyx(\i+1,\j  )}
            \pgfmathsetmacro\bb{fyy(\i+1,\j  )}
            \pgfmathsetmacro\xx{fx (\i+1,\j+1)}
            \pgfmathsetmacro\yy{fy (\i+1,\j+1)}
            \pgflowlevelobj{
                \pgfsettransformentries{\aa}{\ab}{\ba}{\bb}{\xx cm}{\yy cm}
            }{
                \clip(0,0)--(-1,0)--(0,-1)--cycle;
                \tikzset{shift={(-\i-1,-\j-1)}}
                \path(0,0)node{\includegraphics[width=20cm]{lenna.png}};
            }
        }
    }
}

\end{document}

code taken from https://tex.stackexchange.com/a/332173/51022.

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.