Coding Challenge 181: Weighted Voronoi Stippling

  Рет қаралды 176,152

The Coding Train

The Coding Train

Күн бұрын

Пікірлер: 202
@TheFlimTV
@TheFlimTV 9 ай бұрын
I love how this feels both like a University Lecture, and a kids educational channel!
@jounouchi123
@jounouchi123 Ай бұрын
the pinnacle of eli5
@fuschia-draws
@fuschia-draws 22 күн бұрын
perfect videos for adults who loved bill nye as kids
@DanielMiclos
@DanielMiclos 9 ай бұрын
I just wanted to drop by and express my heartfelt appreciation for the amazing content you've been sharing on your channel. Your videos are not only educational, but also a huge source of inspiration for me and many others in the coding community. The generosity with which you share your knowledge and passion for coding is truly commendable. Thank you for being such a fantastic resource and for all the hard work you put into making complex concepts accessible and fun. Keep up the incredible work!
@tiagdvideo
@tiagdvideo 9 ай бұрын
100%!
@Haagimus
@Haagimus 9 ай бұрын
Would like to second this as well Daniel for making both education and programming fun and at the same time. I've watched you for years and years and I have always enjoyed everything that you've made, especially the coding challenges. For a little while, I even replicated some of the coding challenges in Python using the p5 package for python. Keep up the great stuff and don't ever stop Sir!
@arikardasis
@arikardasis 9 ай бұрын
I was going to say "This rules. You rule". But your's is more good words.
@vcvracarkad
@vcvracarkad 9 ай бұрын
I'd love to see this done for each R G B channel individually. i think that would create a really cool comic book type of effect.
@xM0nsterFr3ak
@xM0nsterFr3ak 9 ай бұрын
14:40 "This is lovely, but it's collapsing into an black hole..." That's a very funny quote 😂
@GoldbergToastyBred
@GoldbergToastyBred 9 ай бұрын
it looks so organic there
@jaredgreen2363
@jaredgreen2363 9 ай бұрын
Accidentally made a gravity simulator…
@nicolaswinck9562
@nicolaswinck9562 9 ай бұрын
how fascinating it was to see Gloria Pickle turning into Gloria pixels! you make it look so easy!
@radadadadee
@radadadadee 9 ай бұрын
I program for a living and I couldn't agree more. He makes it looks so easy! But I know it's much more complicated, he's just so good at his job.
@orangejuice732
@orangejuice732 9 ай бұрын
In college a was an undergraduate research assistant converting a 2d voronoi lattice simulation to 3d. 7 years later I think I finally have a grasp on what that simulation was actually meant to do because of this video so thank you.
@conorohagan9947
@conorohagan9947 9 ай бұрын
I love your enthusiasm and I really appreciate that you show your mistakes and laugh about them. Let's be honest, learning to program is boring. You make it really fun.
@guzman-do
@guzman-do 3 ай бұрын
This channel is the best programming channel on KZbin... You make the most difficult concepts simple.. amazing
@sentinelaenow4576
@sentinelaenow4576 9 ай бұрын
The Coding Train is by far the most awesome educational and inspiring coding lessons there is. Thank you so much for sharing your coding adventures, you are the best. ♥
@mariovelez578
@mariovelez578 8 ай бұрын
Can’t believe this guy taught me so many wonders of coding back in the day and he’s still going! Keep up the good work!
@krepker
@krepker 9 ай бұрын
Mindblowing His ability to pick some abstract concept and just use it to solve an real problem in minutes
@Rand00mThing
@Rand00mThing 9 ай бұрын
Wow I admire your coding skills. I could not do what you keep doing. I don't have the passion to always throw myself into new coding problems. I will never forget you, "Coding Rainbow" 🙏
@MyCodingDiary
@MyCodingDiary 9 ай бұрын
You're doing a fantastic job. Don't ever stop creating!
@CocoaBeans660
@CocoaBeans660 9 ай бұрын
This guy makes me so happy and is such an inspiration for KZbin and coding in general. I love it
@barco10001
@barco10001 9 ай бұрын
In all my (few) but intense years of learning creative coding I have not had a greater source of learning and inspiration from your channel. Your ways of teaching and exploring deep and complex topics of creative coding are amazing, fun, and highly enjoyable. The coding community cannot thank you enough!
@TheMasonX23
@TheMasonX23 9 ай бұрын
As a former graphics programmer, I loved this! Also, your enthusiasm and positivity is infectious! Love it man, always happy to hop on board!
@dr_ned_flanders
@dr_ned_flanders 9 ай бұрын
Wonderful video, Daniel. I love how each video is so visual and leads me to learn a new algorithm or mathematical technique as well as improving my coding.
@HeadmostCantaloupe
@HeadmostCantaloupe 7 ай бұрын
I love the new editing style Dan! Feels refreshing to see intros and the Apple ][ jingles being used in the beginning of the video!
@dgo4490
@dgo4490 9 ай бұрын
This algorithm is good for relaxing UV maps for unfolded meshes for artist texturing. The "raster dots" effect can easily be achieved by averaging the image into boxes of n by n pixels and drawing a circle scaled to the magnitude of the average value. Instead of scaled the dot can also be proportionally occluded by another offset dot masking it out, or a hole dot within the dot and whatnot...
@RyanMcCoppin
@RyanMcCoppin 7 ай бұрын
Dude, you are doing a great job. You are personally entertaining, you are providing problem solving techniques and the projects you are doing are very cool. I'm glad I found this channel.
@cashewABCD
@cashewABCD 4 ай бұрын
Watching these for free, what a great world your building, thank you!
@munzeralseed
@munzeralseed 9 ай бұрын
Love it! It reminds me of a technique you used before, which is Floyd-Steinberg dithering. However, this one seems more challenging since you used an external library, but it sets a challenge to write the whole algorithm from scratch and optimize it, which I think I will attempt!
@TheCodingTrain
@TheCodingTrain 9 ай бұрын
oh, please do! I would love to see it!!!
@SianaGearz
@SianaGearz 9 ай бұрын
Floyd Steinberg performs error diffusion in some direction, whatever direction you're scanning towards, say towards bottom right, so if you apply it to a moving image, your start of scan is relatively stable say top left corner but your bottom right is very noisy. This isn't visible in static images, only moving. You could potentially start scanning out from the middle but that doesn't really solve the problem, it will still be obvious where the noise is eminating from. There's a more modern algorithm with a similar visual outcome to Floyd Steinberg but without bias in any direction, where you use a precomputed blue noise as a threshold function, and you can reuse the same across frames or use a spatiotemporal variant, and the way to compute this blue noise, the foundation is in this very video - Lloyd's Relaxation of a random point set. Blue noise sampling is the foundation of a lot of modern stochastic rendering methods in graphics. There's a whole research group at Nvidia concerned with blue noise.
@landsgevaer
@landsgevaer 9 ай бұрын
You don't need voronoi for how it was eventually done. You could just determine the point that is closest to the pixel ... (That point's voronoi cell will contain the pixel.)
@a.lollipop
@a.lollipop 5 ай бұрын
​@@landsgevaer the voronoi diagram is necessary for getting the polygons whose centroid the points move to.
@landsgevaer
@landsgevaer 5 ай бұрын
@@a.lollipop Like I said, you don't need it anymore the way it was eventually done. I gave the much simpler alternative above...
@menaced.
@menaced. 9 ай бұрын
This is basically just shader math, you should try doing a video about/using glsl or hlsl, theres some fun stuff you can do with them, maybe use shader toy? (Never used it bc Im a gamedev so use shaders in engine/in opengl)
@Flackon
@Flackon 9 ай бұрын
Back in the day I made a random map generator and the coastlines and elevation features were drawn via voronoi diagrams. I coded the main app in p5 but also imported d3 for the voronoi computations, so, yeah. No shame in that, lol.
@rohitwesley
@rohitwesley 9 ай бұрын
Hay i been braking my head on this algo for the last yr, was exploring how to go from delaney to nanite 😂 and went as mad as you have, 😅 the fact that u had a hard time, makes me not feel so dumb anymore, not to take anything away from you, love your stuff watch as many as i can, would love to see you experiment with shadertoy constraints and do some crazy stuff 😊
@hamiltonianpathondodecahed5236
@hamiltonianpathondodecahed5236 9 ай бұрын
Every time you introduce some idea, I feel like, "yeah sure, I know the math, that's how that works, no way you can implement it in a single video", then you simply code it up. I am amazed.
@aeschynanthus_sp
@aeschynanthus_sp 8 ай бұрын
The formula for the area of a polygon is the famous shoelace formula! Mathologer, among other people, has a nice video about it.
@ThugLifeModafocah
@ThugLifeModafocah 9 ай бұрын
I understood the absolute number of ZERO things. Thank you.
@JUNGELMAN2012
@JUNGELMAN2012 8 ай бұрын
Hands down....Black belt in coding. I love it.
@pattvira
@pattvira 9 ай бұрын
I felt so relaxed watching this 😌with a nice touch of Dan's enthusiastic sounds every time he got the next thing to work. Jokes aside! Got lots of inspiration from this tutorial - thank you Dan!
@TheCodingTrain
@TheCodingTrain 8 ай бұрын
Thank you Patt!
@paper_airplane
@paper_airplane 9 ай бұрын
Just wanted to note that there are more sophisticated stippling algorithms, like the one based on power diagrams, which is a generalization of Voronoi diagrams (implementing it _is_ a coding challenge). See "Blue noise through optimal transport" paper for details. Besides, you check whether the center of each pixel is inside the Voronoi cell to calculate its mass center. Considering each pixel as a square and calculating the intersection area with each Voronoi cell will give a significant quality improvement for the Lloyd algorithm.
@galzajc1257
@galzajc1257 9 ай бұрын
fun fact: we just had those in our first lecture of solid state physics this monday. i'm deffinitely tempted to make a 3D version of this, and make it efficiently, that seems like a fun geometric problem.
@MarioTorre
@MarioTorre 9 ай бұрын
Pretty good stuff. This seems a very useful method to correctly simulate film grain in a digital photo
@astropgn
@astropgn 9 ай бұрын
This has been my favorite channel since I don`t know, 2017
@Hamomim1
@Hamomim1 9 ай бұрын
My brain hurt, but I was amazed by the beauty of mathematics and your explanation. I have been following it more or less for years. thanks
@Tomtekavler
@Tomtekavler 9 ай бұрын
I can't and have never coded in my life but i still love your videos!
@SianaGearz
@SianaGearz 9 ай бұрын
You can. Just start somewhere and one step at a time.
@tiosam1426
@tiosam1426 9 ай бұрын
It's a translation of light and shadow with a circle radius variation.
@DarkoRomanov
@DarkoRomanov 9 ай бұрын
The black holee is mesmerizing
@yertzar775
@yertzar775 9 ай бұрын
This is actually part of Solid state Physics formulation of the K-Space for electrons
@allaze-eroler
@allaze-eroler 4 ай бұрын
It’s been YEARS (about 5 to 8 years) that i was looking something exactly that! It would have been immensely interesting to adapt it as a lizard skin! I’m now curious how it will be done with blender (open source 3D modeling software) my idea was to use the white color as inexistant scale while the black color would represent the smallest scale of a lizard. Your example is exactly what I’m trying to reproduce as a lizard skin generator! Anyway, thank again for the amazing video you did here!
@kuoyulu6714
@kuoyulu6714 9 ай бұрын
I have no idea whats going on but this is so cool 😃
@randospawn7495
@randospawn7495 9 ай бұрын
I like dithering in art, it looks cool
@EXPLAIN_TO_YOURSELF
@EXPLAIN_TO_YOURSELF 8 ай бұрын
Maybe I should leave a comment on each video you upload. Whenever I'm coding or facing a task, I play one of your challenge videos. They inspire and empower me to overcome the obstacles in my tasks.
@BillionPlusOne
@BillionPlusOne 8 ай бұрын
This was super fun to watch, thanks so much!
@HomeofLawboy
@HomeofLawboy 9 ай бұрын
14:43 God coding the fabric of spacetime
@mrmb84
@mrmb84 9 ай бұрын
The black hole! 😯 Unexpected but so cool!
@Autopawn
@Autopawn 9 ай бұрын
Thank you! Your work is inspiring 😄
@soadsam
@soadsam 9 ай бұрын
babe wake up! new coding train video just dropped!
@HexaflexagonFan
@HexaflexagonFan 8 ай бұрын
the point where you made the points relax based on the centre of gravity could (maybe) be used for liquid simulation
@PeterHellmich
@PeterHellmich 9 ай бұрын
Could be a beautiful effect to transform from the totally distributed dots to those of the image.
@munzeralseed
@munzeralseed 9 ай бұрын
He already did it with the logo at 0:09 and it looks so cool!
@PeterHellmich
@PeterHellmich 9 ай бұрын
Okay but how? Simply the reversed process?
@munzeralseed
@munzeralseed 9 ай бұрын
Yes I think so
@GoldbergToastyBred
@GoldbergToastyBred 9 ай бұрын
Im so excited! I saw your video on nebula tv but i didnt had any subscription so i couldnt watch i didnt think you would upload it this early
@gazzaka
@gazzaka 9 ай бұрын
You are brilliant...loving the videos, thanks 🙂
@xenedon1509
@xenedon1509 9 ай бұрын
well that was awesome
@sachinsurya007
@sachinsurya007 8 ай бұрын
You are Bob Ross of programming
@kasperchristensen8416
@kasperchristensen8416 9 ай бұрын
Thank you for another great video, Mr. Shiffman 😁👍
@olli3686
@olli3686 9 ай бұрын
Wow! Last week, I wrote a kinetic voronoi algorithm which doesn't require any triangularization
@anon_y_mousse
@anon_y_mousse 9 ай бұрын
This does look like fun. I think I'll try it in C with RayLib, and use color. This might make for a really cool image viewer.
@gfabasic32
@gfabasic32 9 ай бұрын
Such a great series!
@landsgevaer
@landsgevaer 9 ай бұрын
Instead of converting points to voronoi, and then figuring out which polygon a pixel is in, you could just determine which point is closest to the pixel... (The trick with remembering the previous pixel's index still works, or you could use a k-d Tree to make it efficient.)
@adamgliwa896
@adamgliwa896 8 ай бұрын
Hard work, and good explanation. Very helpful! 👍
@KeithKritselis
@KeithKritselis 9 ай бұрын
“Let's put them into an array. And lerp the original points towards the centroid.” It seems weird that I understand that...
@YuHayate
@YuHayate 8 ай бұрын
Coding Challenge 182: edge detection?
@PaulMurrayCanberra
@PaulMurrayCanberra 9 ай бұрын
@4:31 Other ways to convert an array of x/y into a flat array of pairwise numbers: const somePoints = [{x:1,y:2},{x:3,y:4},{x:5,y:6}]; const method2 = []; somePoints.forEach(p => { method2.push(p.x); method2.push(p.y); }); console.log(JSON.stringify(method2)); const method3 = somePoints.reduce((vec, p) => vec.concat([p.x, p.y]), []); console.log(JSON.stringify(method3)); .forEach is quite a bit better than writing for loops. .reduce is for functional programming weenies, although it is admittedly cool and tends to be compact.
@kevinrichter6503
@kevinrichter6503 8 ай бұрын
Small mistake on 9:07, where the last circumcircle of the right triangle should be. But overall, that was a fun and educational coding challenge! As always ;)
@aleksander5127
@aleksander5127 9 ай бұрын
​ I love your content. If you allow me, here is a suggestion. You could implement an algorithm to find the path to the goal on the Micro Mouse Race.
@PumpiPie
@PumpiPie 8 ай бұрын
amazing :D
@aquelaquelaquelaquel
@aquelaquelaquelaquel 8 ай бұрын
Man.. I really love your videos although I don't code almost at all.. but damn i like how you integrate things that are pure abstractions for me into applicable real projects. You are a true professor.
@riccardoronconi2146
@riccardoronconi2146 9 ай бұрын
Well. This was pretty amazing
@RedHair651
@RedHair651 9 ай бұрын
I'm currently learning Apps Script for work as a Python person in private, and this video gave me violent flashbacks.
@metallust
@metallust 9 ай бұрын
Cool as always
@Crazyclay78YT
@Crazyclay78YT 9 ай бұрын
oh man ive been wanting to do this
@adrinoadrino6832
@adrinoadrino6832 9 ай бұрын
Reminded me of Origami and Crease Pattern
@realcygnus
@realcygnus 9 ай бұрын
Good one Dan !
@knevari3952
@knevari3952 9 ай бұрын
You are the best !
@geoffwagner4935
@geoffwagner4935 8 ай бұрын
Who ever decided on "ducks" at Columbia Collage was a genius, you'd have to be to pick an animal that just says quack all day long as they walk up and down the sidewalk.
@nembobuldrini
@nembobuldrini 9 ай бұрын
fascinating and relaxing
@samable9585
@samable9585 9 ай бұрын
I like ,relax, followed by head scratching 😂😂
@agzertuche
@agzertuche 9 ай бұрын
Thanks!
@flameofthephoenix8395
@flameofthephoenix8395 8 ай бұрын
0:39 Yeah! I kind of am a little confused about that particular thing, currently what I've always thought them to be was when you take a bunch of points with a given radius, then starting with the highest radius and going down just render every circle, then bits closer to a point will be prioritized over ones further resulting in segments being created. But it was never really clear whether this was actually Voronoi or just another simpler method intended to replicate it.
@flameofthephoenix8395
@flameofthephoenix8395 8 ай бұрын
8:29 Ah! So, it sounds like the method I learned actually is Voronoi and it's much more efficient for finding the areas than the method of having each pixel calculate their distance.
@flameofthephoenix8395
@flameofthephoenix8395 8 ай бұрын
While unrelated to this particular video, surely this comment section is as good as any! I was thinking about how it may be nice to see what you can do with exclusively bill-boarding in 3d graphics, there's of course traditional bill boarding, but you can also make other bill boarding rendering techniques, like for instance rendering 3d lines, this is where you position your image in-between the projected versions of two points then scale it up according to the distance between them and rotate it to fit between, this works really well for a similar cost to standard bill-boarding, you can also do something similar to traditional bill boarding but where you place the image at the incenter of the projected version of a 3d triangle and of course scale it to the size of the incenter too, though I haven't worked out how you could also try incorporating rotation into that to make it a little better. Regardless, I'm curious just how far you could go with just methods like these, I've already made some interesting things with it like a spider since spiders are mostly just lines anyway that could be made out of the 3d line rendering, similarly skeletons would be easy, but for anything beyond that you may need to get super artistic with both traditional and incenter bill boarding plus possibly making new rendering techniques.
@vicentesoto1628
@vicentesoto1628 9 ай бұрын
geez xD this is high vibration content Loved it Is it maths, cs or stand up comedy though
@StefanWolfrum
@StefanWolfrum 9 ай бұрын
Wow, so cool!!! ❤
@IgneousGorilla
@IgneousGorilla 9 ай бұрын
Amazing video!
@tyhuffman5447
@tyhuffman5447 9 ай бұрын
Stunning as always!
@TheCodingTrain
@TheCodingTrain 9 ай бұрын
Thank you!
@programmieraufgaben8391
@programmieraufgaben8391 9 ай бұрын
thats cool!
@flameofthephoenix8395
@flameofthephoenix8395 8 ай бұрын
Hm, I think the fact that you've once again reverted back to averages instead of properly finding the centroid but weighted, the black hole problem is likely still back at least to an extent. If your image was either consistent brightness or a brightness according to the distance from some vector, then the points would likely all collapse into the same place.
@flameofthephoenix8395
@flameofthephoenix8395 8 ай бұрын
Hm, after some thought, here's a potential way to weight the centroid towards certain values, first you compute the normal centroid, then you interpolate each Vertice from itself to the centroid based on its weighting then you recompute the centroid with the new vertices to get the weighted version. I don't know if this is the best method of doing it, but it's worth a shot!
@Sama_09
@Sama_09 8 ай бұрын
Now we need this in python
@regicsf
@regicsf 9 ай бұрын
That is the K-Means algorithm right there.
@stabilini
@stabilini 9 ай бұрын
Amazing content, thanks !
@Jova
@Jova 9 ай бұрын
Awesome!
@npexception
@npexception 9 ай бұрын
This looks like a great way to create something that can be fed to a pen plotter. I imagine a giant stipple plot of a picture of my cat :D
@clearwavepro100
@clearwavepro100 9 ай бұрын
Excellent!! :)
@wongqtr
@wongqtr 3 ай бұрын
I barely understood anything but all I understood was "little dots move around and make cool shapes, man codes them to make image"
@delqyrus2619
@delqyrus2619 9 ай бұрын
2:31 I would name my library "delaunaway".
@JaafarCherkaoui
@JaafarCherkaoui 8 ай бұрын
Nice
@Versette
@Versette 9 ай бұрын
The moment I finished reading the video's title is when I failed the challenge 😅
@RikMaxSpeed
@RikMaxSpeed 9 ай бұрын
No prizes for all those global variables (and name clashes).
@MartinSvandaDeveloper
@MartinSvandaDeveloper 6 ай бұрын
oooooh man you are really crazy
@undergraduate6050
@undergraduate6050 9 ай бұрын
It is used in that point me website.
@jvsonyt
@jvsonyt 9 ай бұрын
15:08 it would be cool if you wrapped the averaging code in an "if then" with a size greater than or equal to like 9 pixels or something to limit how deep the blackhole became
Coding Challenge 182: Apollonian Gasket Fractal
56:48
The Coding Train
Рет қаралды 87 М.
Coding Challenge 171: Wave Function Collapse
1:18:37
The Coding Train
Рет қаралды 554 М.
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 6 МЛН
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,6 МЛН
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
Натурал Альбертович
Рет қаралды 4,4 МЛН
Yay😃 Let's make a Cute Handbag for me 👜 #diycrafts #shorts
00:33
LearnToon - Learn & Play
Рет қаралды 117 МЛН
Apple ][ Coding Challenge: Fractal Tree
35:35
The Coding Train
Рет қаралды 375 М.
Coding Adventure: Rendering Text
1:10:54
Sebastian Lague
Рет қаралды 746 М.
Coding Challenge 177: Soft Body Physics
29:09
The Coding Train
Рет қаралды 158 М.
How I animate 3Blue1Brown | A Manim demo with Ben Sparks
53:41
3Blue1Brown
Рет қаралды 1 МЛН
Collisions Without a Physics Library! (Coding Challenge 184)
31:05
The Coding Train
Рет қаралды 124 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 294 М.
How on Earth does ^.?$|^(..+?)\1+$ produce primes?
18:37
Stand-up Maths
Рет қаралды 418 М.
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Рет қаралды 2,6 МЛН
Coding Challenge 168: MandelBulb 3D Fractal
28:02
The Coding Train
Рет қаралды 375 М.
Coding Challenge #98.1: Quadtree - Part 1
38:08
The Coding Train
Рет қаралды 314 М.
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 6 МЛН