Downtime, technical and personal

To my millions of devoted readers, I apologize for the recent downtime.

From time to time, the script kiddies decide it’s a good time to try breaking into any WordPress sites they can find. This is one of them. Thankfully, my hosting service, NearlyFreeSpeech.net (blatant plug), is clever enough to detect these incoming attacks and preemptively disable the blogs under siege. When the kiddies get bored and the flood of requests ends, I need to log in and reset the system.

Except sometimes I forget. I’ve got a few issues.

Speaking of issues, one of my doctors changed one of my medications and few weeks ago. My sleep got terribly disrupted, my logic circuits got drowned out by static, and I spent the last few weeks being unproductive.

I slept about 10 hours last night and maybe even more the previous night. I’m finally feeling semi-productive and ready to work and contribute again. Before 7:30 this morning, I finished an outstanding KDE patch and hope it will be approved. I’d like to commit it to the master code and get it off my plate.

I’ll have some more details on how I’ve spent my time in the next post.

Training an AI

Artificial intelligence systems aren’t born smart. They have to be taught and trained. If you’ve got an iPhone, you might remember training Siri by repeating a few phrases, like “Hey Siri, it’s me”. That’s how it learns your voice – accurately. I believe Amazon’s Alexa has a similar feature.

But these guys have a head start: a huge set of training data. For the most part, your system already knows how to hear and understand you. That’s because big companies like Apple and Amazon have the resources to run a zillion samples through their speech recognition system and teach it.

Now consider an independent AI assistant, one that doesn’t spy on you or use your data for marketing purposes. That would be Mycroft, which I’ve written about before. I don’t have one of their standalone devices, but I do have the KDE desktop widget up and running. It’s not perfect, but it’s free, open source, and it does indeed work.

Here’s a clip of it in action. You can’t hear me, but you’ll see it processing and hear it answering.

 

It’s not perfect by any means, but considering it’s built by volunteers with donated money, I think it’s pretty impressive.

They’ve got a new project underway right now: training a better voice recognition system. A screenshot of it is at the top of this post.

What they’ve done is gotten the community to submit a collection of training data – people from around the world waking up Mycroft by saying “Hey, Mycroft.” The rest of us get to listen to the samples and grade the clarity of the recording. If you definitely hear “Hey, Mycroft”, you give that sample a thumbs-up. If it’s murky or unclear, you tag it as a maybe. And of course, if it’s just background chatter or noise, you flag it as a negative.

All this (anonymous) data is used to teach the AI what “Hey, Mycroft” sounds like. The community provided the samples, now the community is helping to teach the AI.

It’s really pretty cool. Although I admit my bias and fondness for the KDE ecosystem, Mycroft still has catching up to do. It’s not nearly as responsive as Alexa or Siri, but it simply can’t match Amazon or Apple or Google in terms of development resources. And so I pitch in. I’ll take a half hour to listen to samples and grade them. I’ll fiddle about with the desktop widget and report bugs or issues.

Because it’s open source, I might even dream up and program a skill for it.

After I do everything else on my list, naturally.

Patching Plasma’s file manager

My latest patch for KDE was purely cosmetic, but it was to a key component: the system file manager, known as Dolphin.

A user reported that, when increasing the system font size, the icons would lose their horizontal centering. It’s not a huge deal, but KDE takes a lot of pride in producing a professional product. In fact, my mentor is a user interface/user experience guy, so these kinds of things get his attention.

It was a small task, but Dolphin is a large project. The whole package is spread over 426 files and an estimated 36,992 lines of source code*

Before patching, the icons got stuck to the top boundary of their rows:

This was only evident when the font size rendered larger than the icon size. It went unnoticed for ages, until an astute user reported the issue.

I reworked the Y position for the icons, basing it off the centerline of the text. Previously, the Y calculation was a wonky combination of the icon height and the padding around rows. It didn’t work properly, at least not under all conditions.

With my change, everything stays centered:

Special thanks to the original author – or maybe a subsequent maintainer – for writing in the debugging code that draws those frames around the items.

Naturally, that’s not the normal view:

It came in very handy for checking the alignment.

My patch is still in for review. It’s very minor (what KDE calls a “junior job”), but it’s how new contributors get exposed to the products and how they’re created and maintained. Reported bugs or feature requests that are limited in scope or scale get flagged as junior jobs, ideal for newcomers to practice on. I’ve done a handful of them now. But it’s only recently that I’ve gained the confidence to attempt surgery on major components of the system, as opposed to an isolated application. Even if my fix is approved, it won’t see the light of day for several months. KDE also follows a strict release schedule. Hell, this wide-ranging global free software project is better organized than some multinational corporations I’ve worked for. And they’re sufficiently confident in their review processes that they let “just anyone” take a crack at fixing problems.

I’ve still got ground to cover before they’ll grant me a developer account, which would allow me to publish changes myself. But the more small things I fix, the more experience I’ll gain. I think this was straightforward in the end; the hardest part was finding the two lines of code that needed adjusting.

And I think I accomplished it without causing any damage to a key system component.

 


*calculated with David A. Wheeler’s “SLOCCount” tool

 

 

Praise The Blue Steel

Updated this page’s header image with something a little less monotone. Of course, it’s a Propaganda tile, called Praise-The-Blue-Steel-1. I ran it through GIMP to wash out the colors a little and tile it to the appropriate size. The original is on the left.

I’ve had some partial success with my project to write an application for searching the Propaganda tiles by color. I’ve extracted the top three colors from each image, along with the percentage of each. I’ve run a few tests to calculate the “distance” between a chosen color and the most-prominent (highest percentage) color in the images.

The good news is that the algorithm is fast. Processing the images and extracting the colors took some time (maybe two hours total, for 1,000+ images), but the mathematical formula to find the closest matching color is impressively fast. It should be even a shade faster when I rewrite it in C++ instead of Python.

The issue I’m running across isn’t my fault or a flaw in the code, but a fact about the tiles themselves. Most of them are predominantly dark. So if a user chooses a bright, vivid color, the closest match may not be as bright.

For example, look at the original Praise-The-Blue-Steel up there. Its dominant color, at 40.1%, is this extremely dark shade of blue:

That’s according to the mathematics. To my eye, the image “feels” much lighter than that. I’ve run the image through two different color-extraction routines: k-means clustering and finding the maximum eigenvalue. I don’t understand the calculus behind either implementation, but I know they generate nearly-identical results. So who am I to argue with the math?

Well, I’m me and I argue with the math. I don’t like these results.

Perception is reality, and my perception tells me that image isn’t as dark as the swatch. I don’t quite know what to do. I could extract more than three colors, which will certainly include those lighter shades that are catching my eye. But then I’d have to disregard the percentages. I may try extracting five colors instead of three (which will me re-processing all the images) and when I compare, try checking all five colors against the selected color. And see what kind of matches I get.

It’s an interesting problem. It’s also a bear to solve. I don’t have anything written in the way of an interface yet – I’ve just got Python code spitting out raw data to the console.

But this is how you learn, I suppose. Trial and error. Process and re-process. There’s an entire section of the library at MIT devoted to image analysis, and I’m just a guy in his living room with a laptop and a halfway-decent idea. But we’ll get there. Or we’ll get somewhere. Exactly where remains to be seen… and it’s part of the fun.

Fig. 5

From the days when cool and unusual things were drawn by hand, I present you with Fig. 5:

It’s part of a patent for the use of the HSL color space in computer graphics terminals.

You don’t have to understand it. Just look at it.

It’s spectacular.

 

Mycroft

Wrong Mycroft.

The right Mycroft is an open-source AI speech-enabled personal assistant. That’s a mouthful, but it’s synonymous with one more familiar word: Alexa. Or maybe you prefer Siri. Or Cortana. Or Hey Google, even though that’s two words.

It’s an ambitious project, going up against giants like Amazon, Apple, Microsoft, and Google. But like all good open-source projects, they’re giving it a genuine, honest try.

And the key selling point is… privacy and transparency. They don’t have anything to sell you, so they don’t record them for marketing purposes. The code for all the skills is freely available, so you can inspect it, change it, improve it.

And yeah, it already exists. It’s not just a dream project. Admittedly, the Mark I unit looked a little too cutesy:

But they’ve already raised over $425,000 on IndiGogo for the creation of the Mark II speaker unit, which looks a lot more professional, and more in line with what’s on the market right now:

It can still do smiley faces and whatnot, but it looks a lot more like the rest of the smart-speaker units out there. And again, it’s all open-source, even the hardware. They’ll sell you a development kit that’s just the screen and the guts and let you create your own enclosure. 3D printing interest anyone?

There’s also a prototype desktop widget for your KDE Linux desktop. You can say, “Hey Mycroft” and it perks up and performs a Wikipedia search, gets the weather, etc. Well, it’s supposed to. I’m still in the process of getting it to work. The first hurdle was getting my laptop’s microphone enabled, but that’s not really Mycroft’s fault. The documentation for running this on your computer is a little sparse, at least for this desktop widget. And it’s got a few bugs, like displaying the weather in degrees Kelvin:

I think this has the potential to be a very cool project. I’ve already submitted a bit of code to it, a simple script to help install some of the needed software. But it’s still something. We’ll see if they accept it. Likewise, I’m going to see if I can find the degrees-Kelvin glitch and patch it. It’s the least I can do, considering I submitted a bug report featuring Joe Strummer.

I don’t have it working right just yet. Every time I try to speak to it, it thinks I’m saying “pair my device”. Hmm.

But it’s another cool project to experiment with; something new to try.

And isn’t that what it’s all about, in the end?

Propaganda: Processing Begins

The Image Processing Division of Bundito Heavy Industries reports success in analyzing the first batch of Propaganda tiles.

Terminal output attached as proof of life.

UPDATE (19:03)

I’ve crunched through all 19 (or is it 18.5?) volumes of the Propaganda tiles and stored all the color information in a SQLite database. I’ve got the three most-prominent colors in each image extracted and filed away. There are a total of 1,047 tiles, by the way.

The next trick will be matching that color data to a color chosen by a user. Since it’s unlikely that the user choice will hit an exact match, I need to find colors that are close to the user’s picked color. Finding colors that are close isn’t a straightforward endeavor. There’s going to be more math tomorrow. Lots more math.

In the mean time, I got feedback on some bug fixes I’d submitted for KDE. Henrik has more guidance and specific methods he’d like me to employ. More learning!

 

Acer Aspire E15

With my interest in Linux growing, I decided it was time to get a machine dedicated to running KDE directly. I already had my machine in the basement, which I connected to using NoMachine. It’s an excellent (free!) product if you want to remotely control another computer. I was able to run a reasonably-high quality connection from my MacBook Pro at 1680×1050. The connection never lags on NoMachine; it dials back the quality temporarily when the screen gets busy. That meant that scrolling through long directory listings or pages of source code would go blurry for a moment, then sharpen up. But it still wasn’t like a realtime, live screen. There was always a hint of softness and filtering to the display. Plus, if the thing crashed (more like, if I crashed it), I’d have to go downstairs, climb over bicycles and boxes of CDs, and power on my ancient LCD monitor to see what happened. I know, such a trauma.

But I digress.

After spending my vacation downtime doing research, I settled on the Acer Aspire E15 (specifically model E5-576G-5762; there are multitudes named “E15”). It’s got an Intel Core i5 quad-core processor, 8GB of RAM, a 2GB NVIDIA graphics card, a full 1920×1080 screen, and a 256GB solid-state drive. It shipped with Windows 10 Home pre-installed, so the $599 price tag certainly included the infamous “Microsoft Tax” for an operating system I didn’t want and planned to erase.

My reading and research told me that upon arrival, I should let Windows 10 do its painstaking update processes. Apparently Windows is the only way to update the BIOS on this machine; Acer doesn’t provide any other option. So I let it grind away for the better part of three hours performing updates. Meanwhile, I downloaded the latest developer edition of KDE neon and put it on a bootable USB drive. Once the updates finished, I made a Windows Rescue Disk on another USB drive (I really need to put labels on those…) and prepared to install Linux.

Linux on laptops has traditionally been a tricky proposition. If there’s not a problem with the touchpad, there will be hassles with the WiFi adapter. Or things like not going into suspend mode when you close the lid. There’s so much varied hardware in the world that even the agile open-source community can’t keep tabs on all of it. Which is why I did so much research and bugged so many people on Reddit, Ask Ubuntu, the KDE forums, and elsewhere. Finally I got a handful of partial answers, which I pieced together and decided this machine would work.

Booting from the USB stick was easy and simple. The install was quick and uneventful. I considered shrinking the Windows 10 partition down to the bare minimum and keeping it available as a boot option if I needed it, but at only 256GB, I wanted all the bytes I’d paid for. Plus, I had the bootable recovery USB stick if I needed it (I really need to label that).

The machine booted into KDE quickly and the touchpad and backlit keyboard worked flawlessly, with no headaches. The WiFi, though, was giving me trouble. I kept losing the connection, having to rejoin the network, and then endure awful speeds as I tried to search for the issue. I ended up tethering the laptop to my iPhone over Bluetooth and using the phone’s connection for a while. That worked great.

I narrowed the problem down to two suspects: the WiFi broadcast channel, or the repeater I had plugged in. Changing the WiFi channel made no difference. Once I yanked the repeater out of the wall, the machine snapped to life and browsing the web and downloading updates ran at full speed. I think the repeater and the main router were on different channels, which was causing a sort of interference. Apparently other devices and operating systems can negotiate this, but not the Linux drivers. I need to get that repeater reconnected and reconfigured – I may have reintroduced a problem on my wife’s MacBook Air. But I don’t think so. The Air is a tricky little sucker when it comes to WiFi – troubleshooting it for her in the past (without the repeater, or on hotel WiFi) has proven that much.

The only additional package I had to install was TLP – Advanced Power Management For Linux. It added or enabled kernel modules for full power management support, like dimming the screen when on battery power, or going into suspend mode when shutting the lid.

Music playback is pretty lousy. It’s got typical laptop speakers with no bass and tinny highs. I’d like to connect to my Amazon Echo as an external Bluetooth speaker, but I’ve got some work to do there. The laptop is insisting on pairing with a PIN, which the Echo doesn’t support. PIN-pairing is old-school Bluetooth, and this laptop supposedly supports the almost-latest version of Bluetooth. I’ll get back to you on this.

The screen is nice and sharp, much sharper than the NoMachine connection I was used to. Everything scrolls smoothly and crisply. I’m very pleased. I can’t find which laptop review site said this machine has a lousy display, but they need to clean their eyeballs. I don’t know about off-angle viewing, since I’m the only one using it. I won’t find out how good the screen is in daylight for another couple of months. But I’m perfectly happy. A full 1920×1080 (IPS) display in this price range is uncommon.

The keyboard is a little squishy, as is clicking the trackpad. But this is a $599 mid-tier laptop, not a $2500 MacBook. The body is plastic, not aircraft-grade machined aluminum. But these are compromises I can definitely live with.

So far, my fears about the laptop being underpowered are wrong. Even with a dozen open browser tabs, Thunderbird email, and a music player all running, I haven’t hit the wall on memory or speed yet. I’ve been able to compile code quickly and effortlessly.

In short, a few minor bumps in the road, but I’m overall very pleased. It’s been but a few days, but I’ve made sure they were thorough days with plenty of testing.

And after I peeled off the last of the stickers, no signs of Windows anywhere. Except this damned key on the keyboard…

The Propaganda Tiles, Math Edition

UIn the previous entry in the Propaganda Tiles series, I wrote about the history of the tiles, and my plans to sort them by color. It turns out this requires a dramatic amount of mathematics, almost all of which are miles above my head.

The primary field that works on this kind of image processing is the computer vision branch of artificial intelligence research. Luckily, there’s the OpenCV library – a vast collection of resources and program code – to help out. It’s another one of those remarkable open-source community-run projects that rivals any commercial solution.

I’ll be using some of the OpenCV libraries to process the Propaganda tiles and extract the top three colors in each image, along with the percentage of each. This will be done with a technique called k-means clustering, and this is how it works:

That’s from Wikipedia. I really have no idea what it means. I ain’t never had enough education to learn such fancy math. Heck, I couldn’t even get WordPress to draw a border around the image, so I had to replace it manually.

I realized this morning that searching for tiles based on a chosen color would be complicated. A color is a three-dimensional value, the most common being the levels of red, green, and blue. In the web world, these are expressed as a set of hexadecimal (base-16) numbers, like #a47eb1. That’s a4 (164) for red, 7e (126) for blue, and b1 (177) for green. These combine to make a sort of lavender purple color:

But it dawned on me that I can’t just “add X to blue” to find similar colors, because just moving along the blue scale isn’t helpful. If you take this color and fiddle with only the blue value, it ranges from purple to orange. Adding to or subtracting from all three colors just moves you closer to white or black. Not helpful.

There’s another way to represent colors: HSV, which stands for hue, shade, and value. This method is a lot less intuitive than red, green, and blue. The distinctions between hue, shade, and value are more difficult to grasp, at least for me. The Wikipedia page for HSV (and its cousin, HSL) runs to fifteen printed pages and includes diagrams like this:

 

Which is pretty, and it also makes a kind of sense of the whole HSV concept. But then the math comes in. Again. And you run into things like this:

It’s all three-dimensional computation, polar coordinates, vectors, and other mathematical concepts that are beyond my ability comprehend.

Luckily, I’m using OpenCV to do this work. It has a community of users. Users who are helpful and friendly. I asked my question on the OpenCV forums and got some helpful tips. It appears I don’t have any choice but to learn some of this math if I want my project to succeed. Or I at least need to understand how to use the OpenCV functions. Specifically something called flann. I’ll get back to you once I figure it out.

In the mean time, happy Propaganda to all, and thanks to the OpenCV members who shared their knowledge.

 

The Propaganda Tiles

This is a Propaganda tile.

It’s one of about 1,000 different square images that can be tiled edge-to-edge for a seamless effect. They make great desktop wallpaper.

They were created around 2001 by a Linux advocate named Bowie J. Poag. He wanted to prove the point that a Linux desktop could be every bit as visually attractive as a Mac or Windows desktop. In fact, he wrapped the roughly 17 volumes of Propaganda images in a nutty retro-scifi fantasy tale, starring JFK, who’d faked his death in order to promote Linux through the use of stunning imagery.

The Propaganda Tiles, while once relatively common, have now become a kind of urban legend. A subset of them was apparently shipped with Red Hat Linux at some point. It’s unclear if anyone has a definitive full set. I’ve kept my own copy on various flash drives and backup services for years. I found a set on GitHub to compare against. I compared my set against that and there were omissions and duplicates. I found another copy that still had them separated into the 17 (or is it 18?) individual volumes.

What no one seems to have, though, is that satirical JFK story. It apparently got lost while everyone was most interested in preserving the images themselves. I’ve searched all my copies. I’ve searched the multiple sets I found online. I’ve tried digging through the Internet Wayback Machine to find the original Propaganda site – which has been gone for about 15 years.

While the Propaganda tiles make for great wallpaper or other texturing projects, they’ve got one quirk that makes them difficult to use: their names. The swirly blue tile above is All-Good-People-3. There’s also an All-Good-People-2, which looks like this:

If you examine it closely, it’s the same geometric pattern, but with a different color palette. That’s the one naming rule that stayed consistent throughout all the Propaganda volumes. A trailing number indicated a color variation. Some have as many as 8 variations. But they all have nonsensical names. I don’t know how Bowie chose them. I like to think it’s some kind of surrealist non-statement. The only meaning is the one the viewer assigns to it.

The nonsense names are half the fun when browsing the tiles, but when you’re actively trying to choose a couple to use as wallpaper, it can be frustrating. You can’t remember which one was the cool blue one about two dozen clicks ago. Sure, you could expand your file browser into “preview” mode, but we’re still talking about a collection of over a thousand images.

So I’ve got a plan. And a programming project.

I tracked down the code needed to analyze images and identify the most predominant colors. I thought this would be a simple, if time-consuming process. I was wrong. In order to do it efficiently involves some complex math and statistical processing, most of which is covered by the computer-vision branch of artificial intelligence programming. The mathematics are way, way, above my grade, so I found a site that had a ready-to-use, free-to-use library to do the processing. I ran a handful of Propaganda tiles through it and saw that it would give me exactly what I wanted: the dominant colors in an image. along with the ratios.

So my plan is this:

  • Process all the images through the analysis tool, getting the top three (or five?) colors in each image
  • Stuff all this into a database
  • Code up an application that lets a user choose a color from a color-picking dialog (you’ve all seen those)
  • Find the best-matching Propaganda tiles by looking for that color in the database
  • Look for high-contrast or low-contrast tiles by comparing the “distance” between the predominant colors. A high-contrast tile will have a secondary color that’s vastly different than the most-common color. Think blue with yellow. A low-contrast tile will have similar shades of blue as all the predominant colors – not much distance between.
  • Allow the user to flag tiles as favorites.
  • Set their desktop wallpaper directly from the application, if I can.
  • Preserve Bowie J. Poag’s original tone of conquering the world through more attractive Linux wallpaper.

I believe this project will be called Propaganda For Plasma, as I’ll be using the KDE and Plasma frameworks to code the application. (The initial image analysis will be done in bulk beforehand, using Python, which seems to be the language of choice for the computer-vision crowd.)

And I’ll finally be able to do what I’ve wanted to – browse the Propaganda tiles by color. I love abstract backgrounds, but I’m picky about my colors. I’ve been getting through life well enough up to this point, but it’s a good project.

If I can make it all work, I may even stop using my folder of photos of The Clash as wallpaper.

Or not.

But at least I’ll get to spend more time with the Propaganda tiles.