这个问题已经发布了很多,但是我已经阅读了这里发布的问题,并在不久前构建了我自己的实现。我抛弃了这个项目,在挖掘了一些旧项目后,又遇到了它,于是决定再试一次。但是,我仍然无法确定smooth coloring algorithm的这个实现有什么问题。在
但是,我有一个错误(可能吗?)对于平滑的带状和着色的“图像”(tkinter画布)一般。我想说,这只是我定义的RGB调色板的结果,以及我要去的深度,但我不是百分之百的肯定。它似乎是顺利的大部分,更多关于这个稍后。我会尽量把这件事尽量减少。在
我定义了下面的RGB调色板(137种颜色)here,这是我在一个相当不错的缩放级别上得到的结果,在计算集合时深度达到5000。在
现在,这是它看起来的样子奇怪。这个是在一到两个缩放级别之后,我想说的是,这只是有这么多不同颜色的像素保持乐观的结果。它看起来像是在进一步放大,虽然不太突出自然。在
这是我递归计算集合并对其着色的相关函数
def mandel(self, x, y, z, iteration):
mod_z = math.sqrt((z.real * z.real) + (z.imag * z.imag))
#If its not in the set or we have reached the maximum depth
if mod_z >= 100.0 or iteration == DEPTH:
if iteration < DEPTH:
if iteration > MAX_COLOR:
iteration = iteration % MAX_COLOR
nu = math.log2(math.log2(abs(mod_z)) / math.log2(2)) / math.log2(2)
value = iteration + 5 - nu
print(iteration)
color_1 = RGB_PALETTE[math.floor(value)]
color_2 = RGB_PALETTE[math.floor(value) + 1]
fractional_iteration = value % 1
color = self.linear_interp(color_1, color_2, fractional_iteration)
self.canvas.create_line(x, y, x + 1, y + 1,
fill = self.rgb_to_hex(color))
else:
z = (z * z) + self.c
self.mandel(x, y, z, iteration + 1)
return z
def create_image(self):
begin = time.time() #For computing how long it took (start time)
diam_a = self.max_a - self.min_a
diam_b = self.max_b - self.min_b
for y in range(HEIGHT):
for x in range(WIDTH):
self.c = complex(x * (diam_a / WIDTH) + self.min_a,
y * (diam_b / HEIGHT) + self.min_b)
constant = 1.0
z = self.c
bound = 1 / 4
q = (self.c.real - bound)**2 + (self.c.imag * self.c.imag)
x1 = self.c.real
y2 = self.c.imag * self.c.imag
sixteenth = 1 / 16
#See if its in p2-bulb for different coloring schema between the main bulb and other bulbs of the set
if not (q*(q + (x1 - bound)) < y2 / (constant * 4) or
(x1 + constant)**2 + y2 < sixteenth):
#value of the recursive call while it is not in the set
z = self.mandel(x, y, z, iteration = 0)
if self.progress_bar != None:
self.progress_bar["value"] = y
self.canvas.update() #Update the progress bar
print("Took %s Minutes to Render" % ((time.time() - begin) / MINUTE))
如果以上所述还不够,则发布与计算和绘图相关的完整代码here
你要消除的是混淆。所以解决方案(显然)是消除混叠。分形的一个有效解决方法是自适应超采样。看这个adaptively super sampled mandelbrot sequence。Supersampling只意味着输出中的每个像素都是像素区域中几个样本的平均值(记住,像素不是无限小的点,它们有面积)。可以使用不同的模式,它们在美观性、运行时和实现复杂性之间有不同的权衡。在
像mandelbrot或julia集这样的分形有一个特性,使得自适应超采样成为一个很好的选择:在大的区域中,值变化不大(额外的计算将被浪费),而其他区域的值变化很大。我需要在你的图像中进行大量的改变。有几种方法可以用来确定哪些内容需要大量采样。但有两种方法很容易想到:
相关问题 更多 >
编程相关推荐