Conformal Mapping and Video Generation
What is the mapping?
- Output image coordinates (x_img,y_img) normalized to [-0.5, 0.5] * [-0.5, 0.5] are multiplied by scale_in to obtain (x,y)
- (x,y) is mapped to (u,v) using a conformal or similar mapping.
- (u,v) is multiplied by scale_out, and then mapped to (u_tex, v_tex) such that the part inside [-0.5, 0.5] * [-0.5, 0.5] corresponds to the entire rectangular texture.
- If (u_tex, v_tex) is a valid coordinate in the input texture, we output the (filtered) texel color, otherwise, we output the default color black.
How to get the example results
Environment: Python 3.11. Do pip install -r requirements.txt
to get necessary packages.
python map2video.py color_rotate.png color_rotate.gif --num_frames 40
python map2video.py grid.jpg grid_holo.mp4 --num_frames 40 --map_type holo
python map2video.py grid.jpg grid_anti.mp4 --num_frames 40 --map_type antiholo
python map2video.py grid.jpg grid_exp.mp4 --num_frames 40 --map_type exp --scale_out 0.25 --scale_in 6.28
python map2video.py grid.jpg grid_log.mp4 --num_frames 40 --map_type log --scale_out 0.159 --scale_in 4
The scale in and scale out parameters are chosen so that combining the two mapping should give the identity mapping.
关于二维保角变换
保角变换 Conformal Mapping 可以理解为保持角度不变的映射。参考这里,二维平面中,映射保角的充要条件是对应的复变函数在解析(全纯)且导数不为零。如果映射对应的复变函数的共轭是全纯的,那么映射保角度但会让角的"方向"反向。
exp
比如,对复变函数 $f(z) = e^z$,由于$f'(z)=e^z$,f 在全平面解析,所以带入 z=x+iy
得到的映射(x,y)\rightarrow (e^x\cos(y), e^x\sin(y))
就是一个保角映射。
log
又比如复变函数 $f(z) = \log(z)$,解析,对应的映射是 $(x,y)\rightarrow (\log(x^2+y^2),\arctan(\frac{y}{x}))$,也保角。
antiholo
(x,y)\rightarrow (\frac{x}{x^2+y^2}, \frac{y}{x^2+y^2})
对应的复变函数是 $f(z)=z/|z|^2=\frac{z}{z\bar{z}}=\frac{1}{|z|}$,可以证明它不解析。然而,它的共轭$\bar{f(z)}=\frac{1}{z}$是解析的,因为导数是 $\frac{d}{dz}(\frac{1}{z}) = -\frac{1}{z^2}$。因此,这是一个反方向的保角映射,即这个变换保持角度不变,但会镜像。
它在几何上称为反演变换 Inversion Transformation ,等同于把平面上的点映射到关于单位圆的对称点上:半径变为原来的倒数,角度不变。
holo
$(x,y) \rightarrow (\frac{x}{x^2+y^2},\frac{-y}{x^2+y^2})$对应的复变函数是 $f(z)=\frac{1}{z}$,解析,因此这是一个真的保角映射。