Logo by DsyneGrafix - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Did you know ? you can use LaTex inside Postings on fractalforums.com!
 
*
Welcome, Guest. Please login or register. November 19, 2025, 11:32:12 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Histogram Color and Fractional Iteration  (Read 5171 times)
0 Members and 1 Guest are viewing this topic.
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« on: February 19, 2012, 03:57:01 PM »

I had been looking at this link for explanations of different coloring techniques: http://www.hpdz.net/TechInfo/Colorizing.htm

I finally made sense of how to set up Histogram Coloring at it worked just fine (for Mandelbrot) using integer iterations counts. The problem is that I set up the Histogram count like this (in pseudo-code):

int[] histogramVals = new int[all of the pixels];
for (all of the pixels) {
  while (n < maxIterations) {
    ...run the Mandelbrot tests...
    n++
  }
  histogramVals[n]++;
}

Why I see this as a problem is that the Histogram values are using the number iterations to index the element in the array. This won't work with Fractional Iterations because you can't index with floats. How do people normally set up Fractional Iteration Histogram Coloring?
Logged
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #1 on: February 19, 2012, 04:30:22 PM »

Opps, the length of histogramVal should have been maxIterations

int[] histogramVals = new int[maxIterations];
Logged
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #2 on: February 19, 2012, 11:04:57 PM »

Ok, I found a method that works but it is way too slow. After I get the fractional iteration counts of each pixel I store them into a float array. Then I have one of two options (both are slow):

1. Organize the array with some kind of sorting algorithm (like bubble sort). Then for every pixel determine how many pixels had a lower fractional count (this can be determined from the pixel's index because it is sorted). Use this number divided by the max number of iterations to get a percentage for color.

2. For every pixel, run another loop that counts the number of pixels that have a lower fractional iteration count. Use this number divided by the max number of iterations to get a percentage for color.

Neither of these options are fast. The code I posted above for integer iteration counts was very fast because it sorted a histogram along the way. Is there a method of doing that for fractional counts?
Logged
hobold
Fractal Bachius
*
Posts: 573


« Reply #3 on: February 20, 2012, 07:37:50 AM »

Bubblesort is a very slow algorithm for sorting. As the number N of data items increases, its runtime increases proportional to N*N. You might want to use an algorithm called "Quicksort" instead (which has runtime proportional to N*log(N)), or really anything else but Bubblesort.
Logged
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #4 on: February 20, 2012, 03:15:48 PM »

I know that bubble sort is not the fastest, I just was not sure if people would know what I meant if I didn't provide an example of a sorting algorithm. My goal would be to avoid having a secondary sorting step if it is possible as when I did a histogram color with integers it was not necessary.
Logged
hobold
Fractal Bachius
*
Posts: 573


« Reply #5 on: February 20, 2012, 08:15:56 PM »

My goal would be to avoid having a secondary sorting step if it is possible as when I did a histogram color with integers it was not necessary.
Nitpicking alert! I'll overanalyze things ... (and please forgive me that the information will probably not be helpful for solving the problem at hand).

When you compute a histogram with integers, you actually do a sorting step, namely bucket sort (or radix sort, for a more general name, or spread sort for specific implementation tricks). Each entry in the histogram array is one bucket, and incrementing that array entry is equivalent to putting one unsorted item into the right place.

I am mentioning this to make clear that sorting is always implied when you generate a histogram. I don't think you can do without any explicit or implicit sorting.


If you can get away with less than full floating point precision, you could quantize the input values to buckets of your choice. That means, you could scale those floating point values and round them to integers, and then process the results exactly as in the case where all data starts out as integers. The resulting histogram would be imprecise, of course, but it can be interpolated again and maybe that is already good enough for your purposes?
Logged
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #6 on: February 20, 2012, 09:10:17 PM »

That turned out to be much faster. The multiplier on the floats has some strange effects on the image, it seems best to keep it a small number (like 10). If I make it really big then the fractal starts to glow so intensely that it loses detail and it just looks like bright lightning bolts touching the sections that reached their max iteration count.

Also, when I was using integer iteration counts there were obvious slots (or buckets if I understood your explanation correctly) that I indexed with 'n'. However, for the fractional iteration counts there are no (or at least almost no) repeats of a value for an iteration count. What I mean by this is that each value indexed with the multiplied fractional count doesn't seem to have a repeat. Does this make the coloring rank-order instead of histogram?
Logged
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #7 on: February 20, 2012, 09:30:27 PM »

Opps, never mind the first part of my last post. I actually have no idea what I had made when I wrote that but it wasn't Histogram Coloring. I have it working now, the float multiplier only affects the density of iterations bands which seems to make sense. (If I make it big enough they basically disappear.)

Seems to make sense now, thanks
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Fractional mandelbrot using polar form of complex numbers (new) Theories & Research makc 6 2223 Last post March 20, 2011, 08:18:57 PM
by makc
Histogram/Sort equalization Help & Support SeryZone 13 1555 Last post May 05, 2014, 07:02:31 PM
by SeryZone
Histogram equalization tests Images Showcase (Rate My Fractal) SeryZone 0 1157 Last post May 02, 2014, 07:58:02 PM
by SeryZone
Fractional powers. Is it possible? Kalles Fraktaler paolo 1 3173 Last post October 21, 2014, 07:35:00 PM
by Kalles Fraktaler
histogram colouring is really streching (not true histogram) Kalles Fraktaler claude 3 15147 Last post December 14, 2014, 11:34:00 PM
by claude

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.266 seconds with 26 queries. (Pretty URLs adds 0.011s, 2q)