Pekka Väänänen

@pekkavaa@mastodon.gamedev.place
266 Followers
162 Following
332 Posts

Avid reader, computer graphics fan and atmospheric jungle beats enjoyer.

Demoscene: cce/Peisik.

websitehttps://30fps.net/

New article on my site: HyAB k-means for color quantization

In which I try to improve color clustering with a different distance function. It's a simple technique in the end but it's pretty hard to evaluate if it's an improvement or not!

https://30fps.net/pages/hyab-kmeans/
https://github.com/pekkavaa/HyAB-kmeans/ with #numpy code

New article on my site: HyAB k-means for color quantization

In which I try to improve color clustering with a different distance function. It's a simple technique in the end but it's pretty hard to evaluate if it's an improvement or not!

https://30fps.net/pages/hyab-kmeans/
https://github.com/pekkavaa/HyAB-kmeans/ with #numpy code

This documentation page on #Blender's internal mesh data structure is really good: https://developer.blender.org/docs/features/objects/mesh/bmesh/ It has very thoughtful comparisons to half-edges.

I stumbled upon it when researching mesh libraries for Python that support N-Gons. Perhaps I'll try reimplementing BMesh myself.

BMesh - Blender Developer Documentation

I compared my implementation of Iterative Online K-Means Clustering to the author's C code (Amber Abernathy) and learned that they (a) used a Sobol sequence for random sampling, and (b) assigned each pixel to closest color at the end. Result: No more noise :)
The same algorithm implemented in two programming languages. Guess which one is C 😱

Measured a 256-shade greyscale ramp through my capture card with both on my laptop and the Nintendo 64 (via Retrotink). The response is linear in both (phew!) but I had to mess with the capture card brightness & contrast settings to make the N64 closer to the input. Still clips the whites too early.

#n64 #n64dev

Today I was scratching my head why k-means didn't seem to reduce Mean Squared Error. The clustering seemed fine. Is the error computation broken? How can it be when it's so simple:

def compute_mse(a, b):
return np.mean((a-b)**2)

Well, arguments 'a' and 'b' were images with 8 bits per channel, so...

#numpy

✨ New blog post: "Sharing everything I could understand about gradient noise"

https://blog.pkh.me/p/42-sharing-everything-i-could-understand-about-gradient-noise.html

I had a lot of fun making the WebGL demos, but it took me weeks of work. Boost are really appreciated if you enjoy it.

#glsl #noise #demomaking #shader #blog #programming

Another example on how mean squared error (MSE) doesn't predict final image quality. I implemented Variance Cut Color Quantization in two ways, left is with greedy split plane optimization and on the right side it's with a few rounds of global k-means that results in lower MSE.

I actually prefer the image on the left side since its more detailed.

The algorithm is pretty neat though. It doesn't need a separate initialization step and gradually adds new clusters. Easy to implement too. I tried adding an extra refinement step at the end but it still left some stray "firefly" pixels. Of course it could be a bug in my implementation too, hehe :)