Recent

Author Topic: Buddhabrot fractal: Got the Correct Shape  (Read 2090 times)

Boleeman

  • Hero Member
  • *****
  • Posts: 840
Buddhabrot fractal: Got the Correct Shape
« on: June 01, 2024, 11:51:30 am »
Tried making a Buddhabrot fractal.

Now getting the expected full Buddhabrot fractal shape.
« Last Edit: June 02, 2024, 05:23:05 am by Boleeman »

TRon

  • Hero Member
  • *****
  • Posts: 4158
Re: Buddhabrot fractal: Not getting good shape
« Reply #1 on: June 02, 2024, 01:13:53 am »
Hi Boleeman.

If you take a know outcome then you are able to compare.

So, that is what I did  and can be seen in the picture named original. The picture itself is also a tell-tale sign as of what seem to be going wrong.

Then, taking a look at the code it becomes obvious. You assume that the rawimage data is one block of continues memory with exactly the width and height of the image and top of that assuming that each 'position' is layout as a rgbtripple.

Those are wrong assumptions. You are not allowed to assume anything about the layout in memory of a image except when it is explicitly designed to do so (such as BGRABitmap)

If you fall back to something more robust such as
Code: Pascal  [Select][+][-]
  1. BrotBitmap.Canvas.DrawPixel(x,y, colour);
  2.  
Where colour is of type TFPColor or
Code: Pascal  [Select][+][-]
  1.   BrotBitmap.Canvas.Pixels(x,y) := colour;
  2.  
where colour is of type TColor

... then things are taking shape such as can been seen in the image fixed.
Today is tomorrow's yesterday.

Boleeman

  • Hero Member
  • *****
  • Posts: 840
Re: Buddhabrot fractal: Not getting good shape
« Reply #2 on: June 02, 2024, 05:17:14 am »
Thanks TRon for that advice. Finally got it working with:

Code: Pascal  [Select][+][-]
  1.  procedure TForm1.DisplayBrot(wid, hgt, max_r, max_g, max_b: Integer;
  2.   hit_r, hit_g, hit_b: TIntegerDynArray2D);
  3. var
  4.   x, y, r, g, b: Integer;
  5.   scale_r, scale_g, scale_b: Double;
  6.   pixelColor: TColor;
  7. begin
  8.   BrotBitmap.SetSize(wid, hgt);
  9.  
  10.   if max_r = 0 then
  11.     max_r := 1;
  12.   if max_g = 0 then
  13.     max_g := 1;
  14.   if max_b = 0 then
  15.     max_b := 1;
  16.  
  17.   scale_r := 255 * 2.5 / max_r;
  18.   scale_g := 255 * 2.5 / max_g;
  19.   scale_b := 255 * 2.5 / max_b;
  20.  
  21.   BrotBitmap.Canvas.Lock;
  22.   try
  23.     for y := 0 to hgt - 1 do
  24.     begin
  25.       for x := 0 to wid - 1 do
  26.       begin
  27.         r := Round(hit_r[x, y] * scale_r);
  28.         if r > 255 then
  29.           r := 255;
  30.         g := Round(hit_g[x, y] * scale_g);
  31.         if g > 255 then
  32.           g := 255;
  33.         b := Round(hit_b[x, y] * scale_b);
  34.         if b > 255 then
  35.           b := 255;
  36.  
  37.         pixelColor := RGBToColor(r, g, b);
  38.         BrotBitmap.Canvas.Pixels[x, y] := pixelColor;
  39.       end;
  40.     end;
  41.   finally
  42.     BrotBitmap.Canvas.Unlock;
  43.   end;
  44.  
  45.   PaintBox1.Invalidate;
  46. end;    

Boleeman

  • Hero Member
  • *****
  • Posts: 840
Re: Buddhabrot fractal: Got the Correct Shape
« Reply #3 on: June 02, 2024, 05:30:57 am »
Just wondering how to get that "Mystical Glow Effect" ? Would BGRAbmp be better to use to get that Glow Effect?
« Last Edit: June 02, 2024, 05:41:26 am by Boleeman »

TRon

  • Hero Member
  • *****
  • Posts: 4158
Re: Buddhabrot fractal: Got the Correct Shape
« Reply #4 on: June 02, 2024, 06:06:25 am »
BGRABitmap would not help in that regards.

It is the color mapping method used when generating the fractal that is responsible for what colors are used to draw/generate the image.

Is the original program able to produce this 'glow' image ?

If so then you need to know the parameters used but as far as my knowledge on the buddha fractal goes there are several ways to implement the color mapping and the code as shown does not seem to support generating such 'glow' images.

Perhaps someone more knowledgeable on the subject is able to provide more information.
Today is tomorrow's yesterday.

Boleeman

  • Hero Member
  • *****
  • Posts: 840
Re: Buddhabrot fractal: Got the Correct Shape
« Reply #5 on: June 02, 2024, 06:28:06 am »
Thanks TRon for your reply.

I tried the Glow Effect with BGRABmp and got a dramatic Rendering speed improvement.

About 17 seconds for rendering with fast Gausian Blur on my slow AMD Dell A9 computer.
Can't believe how fast it rendered.

I think a number of people have developed different rendering methods for the Buddhabrot.

Melinda Green discusses The Buddhabrot Technique here: https://superliminal.com/fractals/bbrot/

For that glow effect the website said:

For my color Buddhabrot images the three different threshold values are analogous to the different frequencies of light which NASA combined into their beautiful false-color images.
Color Buddhabrot
For this image I used threshold values of 500, 5000, and 50000, and assigned them to the blue, green, and red channels respectively because this mapping generates images that most resemble the nebula images.

I tried those values in the Lazzed BgraBmp version, but was not seeing that "White Glow" effect. Probably a bit more to the rendering.

The site goes on to say:
Still later while exploring different ways to sample and project these sorts of images, one really surprising thing happened: In one particular rendering projected onto one of the six major planes an image of the logistic map simply popped out! (There are 6 major planes in 4D just like the 3 in 3D.) This had me puzzled for years until 2009 when Taneli Hautaniemi also found it and contacted me. In 2010, Piet en Gilberte then stepped in and made a beautiful animation showing the relationship and added it along with explaination to the Buddhabrot page on Wikipedia. Alex Boswell found an almost magical way to vastly speed the rendering of highly zoomed regions.

Six major planes an image.
Would like to see that.
Actually found a link to the Animated Buddabrot:
The Buddhabrot Fractal in 4K
https://www.youtube.com/watch?v=zxIcydL7wwY



The Buddhabrot converges back to a Mandelbrot then diverges again. Wow !

« Last Edit: June 02, 2024, 07:00:34 am by Boleeman »

Boleeman

  • Hero Member
  • *****
  • Posts: 840
Re: Buddhabrot fractal: Got the Correct Shape
« Reply #6 on: June 02, 2024, 07:18:12 am »
This page has a great discussion: https://benedikt-bitterli.me/buddhabrot/

Download this animation (383 kB in size).

https://benedikt-bitterli.me/buddhabrot/images/transform.mp4

Just so Awesome to watch.

Dzandaa

  • Sr. Member
  • ****
  • Posts: 409
  • From C# to Lazarus
Re: Buddhabrot fractal: Got the Correct Shape
« Reply #7 on: June 02, 2024, 12:38:17 pm »
Hi,

Just for the fun I changed:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.DisplayBrot(wid, hgt, max_r, max_g, max_b: Integer;
  2.   hit_r, hit_g, hit_b: TIntegerDynArray2D);
  3. var
  4.   x, y, r, g, b: Integer;
  5.   scale_r, scale_g, scale_b, Fact: Double;
  6. //  pixelColor: TBGRAPixel;
  7.   glowBmp: TBGRABitmap;
  8. begin
  9.   BrotBitmap.SetSize(wid, hgt);
  10.  
  11.   Fact := 255 * 2.5;
  12.   if max_r = 0 then
  13.     max_r := 1;
  14.   if max_g = 0 then
  15.     max_g := 1;
  16.   if max_b = 0 then
  17.     max_b := 1;
  18.   scale_r := Fact / max_r;
  19.   scale_g := Fact / max_g;
  20.   scale_b := Fact / max_b;
  21.  
  22.   {
  23.   scale_r := 255 * 2.5 / max_r;
  24.   scale_g := 255 * 2.5 / max_g;
  25.   scale_b := 255 * 2.5 / max_b;
  26.   }
  27.  
  28.   BrotBitmap.Fill(BGRA(0, 0, 0, 0));
  29.  
  30.   for y := 0 to Pred(hgt) do
  31.   begin
  32.     for x := 0 to Pred(wid) do
  33.     begin
  34.       r := Round(hit_r[x, y] * scale_r) and $ff;
  35.  //     if r > 255 then
  36.  //       r := 255;
  37.       g := Round(hit_g[x, y] * scale_g) and $ff;
  38.  //     if g > 255 then
  39.  //       g := 255;
  40.       b := Round(hit_b[x, y] * scale_b) and $ff;
  41.  //     if b > 255 then
  42.  //       b := 255;
  43.  
  44. //      pixelColor := BGRA(r, g, b);
  45. //      BrotBitmap.SetPixel(x, y, pixelColor);
  46.  
  47.       BrotBitmap.SetPixel(x, y, BGRA(r, g, b));
  48.     end;
  49.   end;
  50.  
  51.   glowBmp := BrotBitmap.FilterBlurRadial(10, rbFast);
  52.   BrotBitmap.PutImage(0, 0, glowBmp, dmDrawWithTransparency);
  53.  
  54.   glowBmp.Free;
  55.  
  56.   PaintBox1.Invalidate;
  57. end;                                            
  58.  

And

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormDestroy(Sender: TObject);
  2. begin
  3.  if(BrotBitmap <> nil) then BrotBitmap.Destroy;
  4. end;  
  5.  

To gain a little speed and free memory.

Great job, Boleeman

B->
Regards,
Dzandaa

Dzandaa

  • Sr. Member
  • ****
  • Posts: 409
  • From C# to Lazarus
Re: Buddhabrot fractal: Got the Correct Shape
« Reply #8 on: June 02, 2024, 06:16:40 pm »
Hi,

Same version but with a resizable TImage.

Have fun with Budha :)

B->
Regards,
Dzandaa

Boleeman

  • Hero Member
  • *****
  • Posts: 840
Re: Buddhabrot fractal: Got the Correct Shape
« Reply #9 on: June 03, 2024, 04:22:24 am »
DZandaa. I checked the forum and got nice surprise.
Much appreciated for the Buddhabrot updates.


I took a day off work myself, due to a head cold/virus. I work at a college where there are some students and teachers sick at various times.

Nice to hear from you Dzandaa. Was not sure if something may have happened?
Anyhow, looks like everything is OK.

On Github, there are many different versions of the Buddhabrot with different ways of making it so I might look into some of those more interesting methods.

Would love to work out how they rendered the Buddhabrot Curve to make that great animation that morphs between the Buddhabrot Curve and the Mandelbrot Curve.

Just realized I mistakenly left some TEdit in the code from the VB6 code I was using to convert to Lazarus, so please delete as not needed:

    txtWidth: TEdit;
    txtHeight: TEdit;
    txtRedCutoff: TEdit;
    txtGreenCutoff: TEdit;
    txtBlueCutoff: TEdit;
    txtStopAfter: TEdit;
    txtDrawEvery: TEdit;

I noticed that the end result Buddhabrot curve differs slightly each time due to Randomize being used.

Not sure if you can help out with the Trouchet Curve at https://forum.lazarus.freepascal.org/index.php/topic,67394.0.html. Can't work out why it is not rendering correctly.

DZandaa, cheers for now. So glad for your updates and for your reply.

"May the Buddha be with you"
« Last Edit: June 03, 2024, 04:27:44 am by Boleeman »

Dzandaa

  • Sr. Member
  • ****
  • Posts: 409
  • From C# to Lazarus
Re: Buddhabrot fractal: Got the Correct Shape
« Reply #10 on: June 03, 2024, 03:15:43 pm »
Hi,
@Boleeman

I modified the Truchet Curve.

Have a nice day.

B->
Regards,
Dzandaa

Boleeman

  • Hero Member
  • *****
  • Posts: 840
Re: Buddhabrot fractal: Got the Correct Shape
« Reply #11 on: June 03, 2024, 10:01:16 pm »
Found a free Photoshop plugin that makes nice Buddhabrot fractals at:

https://richardrosenman.com/shop/buddhabrot/

« Last Edit: June 21, 2024, 12:18:44 pm by Boleeman »

 

TinyPortal © 2005-2018