关于以图像为轨道陷阱的Julia集着色方法的技术咨询
基于位图轨道陷阱的Julia集着色原理与实现疑问
问题背景
我在网络上找不到将位图(光栅图像)作为轨道陷阱为Julia集或Mandelbrot集着色的完整示例。Inigo Quilez仅用两行代码解释了他的实现方法并展示了生成的Julia集;Malin Christersson展示了相关图像(包括基于《蒙娜丽莎》的Julia集),但未提供任何注释或说明。我希望理解以图像为轨道陷阱的着色方法原理,尤其是图像在复平面中如何放置以实现轨道捕捉。
我的现有实现
我已通过Julia代码实现一种方式:在复平面中定义与图像分辨率一致的矩形网格,迭代网格点直到|z|>2或达到迭代阈值,以轨道最后一点对应的图像像素为初始点上色。代码如下:
using Images, Interpolations f(z::Complex; c= 0.56666-0.5im, n=4) = z^n + c function iteratef(z, iter) k=0 while abs(z) <2.0 && k < iter z=f(z;) k+=1 end return z end function JuliasetImage(img::Union{Matrix{RGB{T}}, Matrix{Gray{T}}}; rectangle=(remin=-1.5, remax=1.5, immin=-1.5, immax=1.5), iter=255) where T #define a constant image for fractal, inialized on white frimg = fill(RGB{N0f8}(1, 1, 1), size(img)...) nrow, ncol = size(img) a, b, c, d = rectangle @assert a<b && c<d || error("wrong boundaries for the rectangle {$a, $b}x[$c, $d]") for j in axes(img, 2) for i in axes(img, 1) z = Complex(a+(b-a)*(j-1)/(ncol-1), d-(d-c)*(i-1)/(nrow-1)) z = iteratef(z, iter) #get indices in the image of the last z idxr = floor(Int, 1.5+(nrow-1)*(d-imag(z))/(d-c)) idxc = floor(Int, 1.5+(ncol-1)*(real(z)-a)/(b-a)) if idxr < 1 || idxr > nrow idxr = mod(idxr, nrow) + 1 end if idxc < 1 || idxc > ncol idxc = mod(idxc, ncol) + 1 end frimg[i,j] = img[idxr, idxc] end end return frimg end img =load("ai-boy.jpg") frimg = JuliasetImage(img;) fritp = interpolate(frimg, BSpline(Linear()), OnGrid())
核心疑问
我已成功生成对应的Julia集图像,但希望理解Inigo Quilez和Malin Christersson两位作者的Julia集具体生成方式。
内容的提问来源于stack exchange,提问作者petem
相关产品推荐
相关产品推荐

