逃逸时间算法中的 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);

 

 

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

 

你可能感兴趣的:(逃逸时间算法中的 NormalizedIterationCount. Normalized Iteration Count 让颜色更柔和)