Welcome to Fractal Forums

Fractal Software => Kalles Fraktaler => Topic started by: claude on December 14, 2014, 05:34:26 PM




Title: histogram colouring is really streching (not true histogram)
Post by: claude on December 14, 2014, 05:34:26 PM
What you call histogram colouring is implemented by:

Code:
		else if(m_nColorMethod==4){
int nMin, nMax;
GetIterations(nMin,nMax);
iter = (double)1024 * ((double)iter-(double)nMin) / ((double)nMax-(double)nMin);
}

This isn't histogram colouring, it's just linearly stretching the range between min and max.

Here's a comparison of stretch colouring vs true histogram colouring:

(http://mathr.co.uk/mandelbrot/histogram/stretch.png) (http://mathr.co.uk/mandelbrot/histogram/histogram-pow1.png)

You can see that true histogram colouring really does give a flat histogram in these screenshots from GIMP:

(http://mathr.co.uk/mandelbrot/histogram/analysis-stretch.png) (http://mathr.co.uk/mandelbrot/histogram/analysis-histogram-pow1.png)

True histogram colouring can look too bright, here's some darker versions made by squaring, cubing, and raising to fourth power (operations applied to colour values):

(http://mathr.co.uk/mandelbrot/histogram/histogram-pow2.png) (http://mathr.co.uk/mandelbrot/histogram/histogram-pow3.png) (http://mathr.co.uk/mandelbrot/histogram/histogram-pow4.png)

Attached is the source code and makefile I used to implement these methods.  True histogram colouring is quite a lot slower than stretch colouring as it needs to sort the whole image by smoothed iteration count, then binary search for the index of each pixel.  This is O(N log N) compared to most colouring methods O(N).


Title: Re: histogram colouring is really streching (not true histogram)
Post by: claude on December 14, 2014, 06:17:55 PM
using histogram for hue, combined with (multiplied by) pseudo-de:

(http://mathr.co.uk/mandelbrot/histogram/rainbow-histogram-with-pseudo-de.png)

(made in GIMP, slight layer misalignment fubar..)


Title: Re: histogram colouring is really streching (not true histogram)
Post by: Botond Kósa on December 14, 2014, 11:08:12 PM
True histogram colouring can look too bright, here's some darker versions made by squaring, cubing, and raising to fourth power (operations applied to colour values):

The histogram coloring in your example looks too bright because the the colors are evenly distributed on all pixels of the image, while the area of main interest is in the middle and contains the high iteration counts from the right side of the histogram and gets colored accordingly. To change the even distribution you can apply a function to the color index that maps the [0,1] interval to itself and is nonlinear. I did lots of experiments with different functions and found that squaring, cubing and other polinomials are not ideal because of two reasons:
  • Their derivative at 0 is 0, meaning they completely wash out features with the lowest iteration counts (on the left end of the histogram)
  • When rendering a minibrot, the iteration count approaching its edge tends to infinity. In order to make features near the edge visible, the derivative at 1 needs to be high, ideally infinite.

Functions of the form 1-(1-x)^(1/m) satisfy both criteria when m>1. When m=2, the function is the x^2 function reflected across the line y=1-x. m=1 turns the function linear, while higher m values increase the nonlinearity of the function:
(http://web.t-online.hu/kbotond/mandelmachine/img/hist_coloring_transfer_functions.png)

In Mandel Machine, the Color density parameter controls the value of m when histogram coloring is used.


Title: Re: histogram colouring is really streching (not true histogram)
Post by: claude on December 14, 2014, 11:34:00 PM
Functions of the form 1-(1-x)^(1/m) satisfy both criteria when m>1.

Very nice analysis!  I added your curve to my histogram program in this commit:
https://gitorious.org/maximus/kf-extras/commit/bf85641fdc0d19196788236b7e5db74c1bd86600
http://code.mathr.co.uk/kf-extras/commitdiff/bf85641fdc0d19196788236b7e5db74c1bd86600