Recent

Author Topic: [SOLVED] Voronoi diagram  (Read 4459 times)

Boleeman

  • Hero Member
  • *****
  • Posts: 721
Re: [SOLVED] Voronoi diagram
« Reply #15 on: July 27, 2024, 03:55:48 am »
Found a nice Fractal like stained glass like Javascript version here:

https://gist.github.com/josdirksen/806e33c678753cd5133c1d40d73e8360

I resized the original GitHub png, as it was too large.

Also attached the html, js source. Looks amazing.


Would be nice to convert to Bgrabmp ?


« Last Edit: July 27, 2024, 04:00:07 am by Boleeman »

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: [SOLVED] Voronoi diagram
« Reply #16 on: July 27, 2024, 12:27:33 pm »
How about this (just pushed the project to my github: https://github.com/wp-xyz/ImagePoster):
« Last Edit: July 27, 2024, 03:32:38 pm by wp »

Phoenix

  • Full Member
  • ***
  • Posts: 109
Re: [SOLVED] Voronoi diagram
« Reply #17 on: July 27, 2024, 10:19:29 pm »
Wow, much appreciated thanks to you both!   :D

Boleeman

  • Hero Member
  • *****
  • Posts: 721
Re: [SOLVED] Voronoi diagram
« Reply #18 on: July 28, 2024, 01:52:30 am »
Wow W.P., that posterizer has some great features. Thanks for the upload.

Even has Lloyds Algorithm (read a bit about it, but did not see it in action).


With the JavaScript version, I tried to convert to BGRAVirtualScreen, but it seems D3.js has some Voronoi seeded function and a random polygons function. I think I may have seen something like the JavaScript version, written in FreeBasic years ago called Fractured Glass.

Thanks W.P. for your nice upload. Very creative use of Voronoi and Delaunay.

Not sure if anyone else is getting an Invalid Operation error with the W.P program when using other images.

I get an error after clicking btnApplyLloydsAlgorithm here:         

w[j] := w[j] / wsum ;              in procedure TMainForm.LloydsAlgorithm;

Possibly because of a divide by zero error because wsum = 0  ?

I don't seem to get that error if I keep on using Lenna.png, but for any other png I get that error.


« Last Edit: July 28, 2024, 12:47:31 pm by Boleeman »

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: [SOLVED] Voronoi diagram
« Reply #19 on: July 28, 2024, 01:37:24 pm »
Can you post that image?

Boleeman

  • Hero Member
  • *****
  • Posts: 721
Re: [SOLVED] Voronoi diagram
« Reply #20 on: July 29, 2024, 08:40:12 am »
Ok W.P.  Attached are the images that had the error come up when Lloyds algorithm was applied.


When running the compiled exe and loading either of the 2 attached pngs and applying the Lloyds algorithm I get an Invalid floating point operation.
When compiling in the IDE and loading either of the 2 attached pngs and applying the Lloyds algorithm I get an FLT Invalid operation at line 502  which is   w[j] := w[j] / wsum;

I had all Tcheckboxes enabled in each case.

That error was not coming up when Lenna_(test_image).png  was used. Not exactly sure why this happens.
« Last Edit: July 29, 2024, 08:51:40 am by Boleeman »

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: [SOLVED] Voronoi diagram
« Reply #21 on: July 29, 2024, 05:51:24 pm »
Please try the new commit.

Boleeman

  • Hero Member
  • *****
  • Posts: 721
Re: [SOLVED] Voronoi diagram
« Reply #22 on: July 30, 2024, 09:28:08 am »
Hi W.P.

The functions work for all png pictures, but the Lloyds algorithm seems to not work for jpg.
Looks like jpg compression is the problem.

I tried the new commit with other png files and have things working correctly (and don't get any floating point error).
Also have the console window appearing.


« Last Edit: July 30, 2024, 09:50:44 am by Boleeman »

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: [SOLVED] Voronoi diagram
« Reply #23 on: July 30, 2024, 02:01:18 pm »
TBitmap.Assign is doing strange things sometimes... Now painted the loaded bitmap to the draw bitmap, and the issue is gone. Also removed the console window (cause by option -WG in project settings).

Boleeman

  • Hero Member
  • *****
  • Posts: 721
Re: [SOLVED] Voronoi diagram
« Reply #24 on: July 31, 2024, 09:11:06 am »
W.P. That latest tweak is working really well for all file types.

I like the triangular gradient fill effect.

Getting some nice results, as shown in attached files.
I used my bevel maker for the framed section.
Perhaps might be nice to have a "apply a frame option".

1st attached png: Applied Lloyd's algorithm (Gives a cool skin-like Voronoi texture).
2nd attached png: Applied Delaunay Border to Lloyd algorithm png (Gives a fibrous texture).
3nd attached png: Applied triangular gradient fill effect (Gives a dreamy picture).

Thank you W.P. for those extra tweaks.

« Last Edit: July 31, 2024, 09:40:48 am by Boleeman »

 

TinyPortal © 2005-2018