The Iron Code



Bits and bytes make the world go round...

While - as you can read in my about page - I wrote a lot of C++ in the past, my current projects are almost purely rust. As a father your spare time gets somewhat limited. Therefore I chose to only code in a language that comes naturally and without most of the pain points of C++ (cmake, dependency management, different compilers on different platforms).


My most recent project is image-compare. It's a crate featuring algorithms for comparing images. Of course, it's tested with cucumber-testing and beyond the pure score allows producing nice grayscale diff-images. Example images can be seen below, a plate of stir-fried holy basil with fried egg and riceberry rice. The first image is complete, the second destroyed / distorted in regions. The third is the pixel-perfect RMS algorithm which captures the black bars nicely but struggles a little with the oil-filter. The final image is produced by MSSIM (8x8 pixels) while it looks unsharper due to the 8x8 windows it actually captures the perceived difference of the oil filter better (in my opinion). Anyway: the choice is yours :)
original image of stir-fried holy basil with two fried eggs and riceberry rice
The original food
Image version of pad gaprao deliberately destroyed
Destroyed version
diff image produces with RMS algorithm
Diff image with RMS grayscale
diff image produces with MSSIM algorithm
Diff image with MSSIM grayscale
In the 0.2 series, the crate also features histogram and several modes of RGB comparisons. It can be MSSIM per channel, RMS per channel or a mode which I call "hybrid compare". This mode transforms the image to YUV and takes MSSIM on Y and rms-distance on UV. The resulting diff-image is a little different to interpret. Black pixels mean no difference at all, red squares denote differences in Y while anything between blue, green and cyan denote a difference in color only. RMS shows the color differences in a nice way but underestimates differences in perceived structure. The MSSIM comparison on the other hand shows the structural differences very well but is very small on the color differences. Hybrid comparison combines both in different color channels.
Image version of pad gaprao broken in structure and color in different places
Image destroyed with median filter (structure) and color filter in different places
diff image produced with rms rgb algorithm Diff image with RMS rgb
diff image produced with hybrid algorithm
Diff image with MSSIM rgb
diff image produced with hybrid algorithm
Diff image with "hybrid compare"
With the upcoming 0.3 release the hybrid compare will be generalized to RGBA with two options. The first is splitting the channels to YUVA and using RMS on the alpha channel. ALso, the difference will be weighted with the mean alpha of the pixels to take into account, that more translucent pixels are more similar to the eye even with more different color values. The second approach is somewhat different as the rgba image is blended with a background color back to rgb. This is more viewer-centric as white and transparent appear the same on a white background, but are completely different on black. The first method will always "measure" the difference while the second method takes the background color as a parameter and only measures the visible difference on that given background.
A red underlined '100' on transparent background
A text image on transparent background
A typed '10ß' with gradient underlining Color changes with red outline.
diff image produced with rgba hybrid algorithm
Diff image with hybrid comparison: Structure in the red channel, color differences in blue and green.

Lazy async promises and a blog reader for this blog

The blog reader is a toy project of mine. I tried to use egui and combine it with async/await (with tokio). The crate for the lazy async promises can be found here, but it's also on with the name "lazy_async_promise". It's not done yet, only a few features exist. I plan to add more and maybe make a blogpost series about it :).
diff image produced with hybrid algorithm
diff image produced with hybrid algorithm