逃逸时间算法中的 NormalizedIterationCount. Normalized Iteration Count 让颜色更柔和

数学公式:

mu = n + 1 - log (log  |Z(n)|) / log p

 

 

以下代码是ruby的。来自http://rubyforge.org/frs/shownotes.php?release_id=38498

NormalizedIterationCount = lambda do |fractal|
      z = fractal.args[:z]**2 + fractal.c; fractal.last_iteration += 1
      z = z**2 + fractal.c; fractal.last_iteration += 1

      modulus = sqrt(fractal.args[:z].real**2 + fractal.args[:z].image**2).abs
      mu = fractal.last_iteration +
        log(2 * log(fractal.bailout)) - log(log(modulus)) / log(fractal.args[:p])

      (mu / fractal.max_iterations * 765).to_i

 

maxima代码

GiveNormalizedIteration(z,c,E_R,i_Max):=
/* */
block(
[i:0,r],
while abs(z)<E_R and i<i_Max
   do (z:z*z + c,i:i+1),
r:i-log2(log2(cabs(z))),
return(float(r))
)$
其中 log2(x) := log(x) / log(2);

C伪代码:

      int iter_count = 0;
      float escape_radius = 20.0;
      complex Z, C;
      loop (forever) {
         Z = Z*Z +C;
         iter_count ++;
         float modulus = sqrt (ReZ*ReZ + ImZ*ImZ);
         if (modulus > escape_radius) goto stop;
         if (iter_count > maxiter) goto stop;
      }
  
   stop:
      Z = Z*Z +C; iter_count ++;    // a couple of extra iterations helps
      Z = Z*Z +C; iter_count ++;    // decrease the size of the error term.
      float modulus = sqrt (ReZ*ReZ + ImZ*ImZ);
      float mu = iter_count - (log (log (modulus)))/ log (2.0);
      color_value = colormap_lookup (mu);
      draw_pixel (C, color_value);

 

 

请看这两幅图片,一个是没有用这个技术的,另一个柔和的是用了这个技术的

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值