Color optimization, take two

An anonymous commenter suggested I use CIE L*a*b* instead of HSV. I’ll let the results speak for themselves:


And that’s without any tweaks, fancy distance metrics, or pushing outside the region when the vector is too short. Whoever you were, thanks for the suggestion! Also, thanks to Madeleine Ball, whose suggestion I misunderstood, but is basically the same.

Update: with some vector extension code (slightly more contrast when colors are really close). The code is in xchat-gnome SVN for everyone to play with now.

Tags: ,

Overengineering beyond all reasonable limits: automatic color palette optimization

A while ago, it was suggested that GTK+ themes provide an ability to define certain colors. The reasoning behind this was that if a theme had a red background for something, just defining red as #ff0000 could result in unreadable text. As usual, some objections were raised, and IIRC nothing has yet happened with it.I was interested in this, because xchat-gnome is one of the very few things where it actually makes sense to define colors by name. It’s all well and good if a theme provides defined colors for heading and alert, but IRC allows people to mark text as red or aqua. Theme based colors weren’t an issue yet, because xchat-gnome worked on purely pre-defined color schemes for the conversation panel. Until now.

Perhaps it’s just been too long since I did any graphics programming, but when I thought this idea up in the shower (as an aside: I have, in the past, been known to take showers for the sole purpose of thinking up ideas), I just had to implement it.

Basically, instead of defining a color as a specific RGB triplet, we define it as a region in HSV space. HSV is a color space that matches more closely to how we as humans tend to define colors. It’s a cylindrical coordinate system where the angle defines hue, the radius defines saturation, and the vertical axis defines “value” (basically white to black). The colors within this cylindrical space fill a conic region.HSV_cone.png
The actual mapping between RGB and HSV forms a hexacone, due to colors in HSV that cannot be represented in RGB. Anyhow, we’re defining colors as a kind of wedge of this coordinate system. That means that when we say blue, we’re not actually defining a color, but a range of colors. Blue can be dark, it can be light, and it can range from purpleish-blue to cyanish-blue.

When the background color is not known a priori, some colors within this region may be too low a contrast to be readable. The background color is a point in HSV space, and by choosing the point within the region which is furthest from our background point, we get a foreground blue which is readable.

Of course, there are still some problems with this. The background color may lie right in the middle of a color region. In this case, even the furthest point within that region is going to have very low contrast against the background. To guard against this, if the hue of the foreground point is too close to the background and the saturation is high, the value gets pushed a little further out. Value (lightness) is a primary influence on how we percieve contrast, so by emphasizing it, the text becomes (mostly) legible.

color_optimization.png As a result of this, colors against a white background tend to be dark, while colors against a black background tend to be light. By defining white and black as regions which have some breadth in the value dimension, white-on-white text and black-on-black text become readable. When on a grey background, text gets pushed in either direction depending on whichever is furthest away in the HSV color space. For the most part, this works very well (you can see the purple color has some problems on this particular shade of grey). Because colors have some breadth in the H and S dimensions, even highly saturated colored backgrounds work well.

Of course, xchat-gnome allows image and transparent backgrounds, which are completely ignored by this. Nothing can deal with high-frequency high-contrast backgrounds, so I’m just going to say if you’re foolish enough to try that, you get what you deserve :). This code has landed in xchat-gnome SVN, and there’s been enough awesome stuff since 0.11 that a new release should be coming soon.

Tags: ,

alpha blended windows in python

Here’s a version of Mike’s alpha demo, in a python implementation that’s more pythoney (rather than a direct translation from C). GTK+/pygtk folks, any chance we could get that compositing-manager detection code out into the world before 2.10? :)

Tags: ,


Well, the grades are in, and while it’s not completely official yet, it’s fairly safe to say I’ve graduated. In addition, after a grueling 4 day search, I put down a holding deposit on a fantastic apartment in Mountain View, CA. Also, I bought a really pretty watch. Now I’m looking forward to a summer of travel and stressless employment, followed by a move across the country to what promises to be a great job.

Life is great :)


Raising my ire and tempting my wrath

I just discovered that the wiki on zero (the host my blog is on) got hit pretty hard by the spammers the last few days — hard enough that I don’t have the energy to clean it up at the moment. I shudder to think what it would be like if I still allowed anonymous edits.

Anyone know of an easily set-up captcha plugin for mediawiki 1.5? Until I have the chance to crack some spammer-skulls, it’s the only thing I can think of to help with the problem.

Tags: ,

Tagging love and community ire

A couple days ago, searching for something cool to hack on, I came back to leaftag. Shortly after I started updating the deskbar handler, Luis Villa posted on his desire for it, and a release got cut. It’s pretty incomplete and buggy, and not very useful right now, but still enough to get a number of people excited.

However, it’s also enough for people to start giving us their opinions. I really don’t know why, but for some reason there’s a large group of people who really want us to use extended attributes to store the tags. Even after giving them a bunch of reasons why it’s not useful for our purposes, they keep trying to tell us how to build our bike shed.

I don’t understand why xattrs are such a big deal, and I don’t understand why everyone cares so much about how our implementation works. They’re never going to touch the code, and as long as it does what they want, why should they care what’s under the hood? I’ve set to see one comment on Christian’s blog that asked for a feature that required xattrs without first saying we should use xattrs. It really felt like all the features they listed were just attempts to justify their position that xattrs are the coolest thing since sliced cheese.

I’m starting to understand why Novell kept Xgl’s development under wraps until things worked.

Maybe I’m only starting to see something that has existed for years, but it really feels like gnome is so encumbered by endless talk, bike shedding and stop energy that very little is happening. The cool things like gimmie, deskbar, nautilus search and leaftag only happen when someone goes off in a corner, shuts themselves out from the community for a while and actually writes some code. The mailing lists and irc channels were recently aflurry with conversation about what “community development” means, and just as quickly as it came, it was gone. A huge amount of time and effort was invested into that discussion, and absolutely nothing came of it. This isn’t an unusual pattern.

I’ve heard it suggested by a couple people that gnome needs a dictator, and I really think that’s the case. At the very least, gnome needs someone who can tell people to shut up and get back to work.

And for all you xattr fanboys, code speaks a lot louder than words. Show us that xattrs provide something useful and good, and we’ll talk. Until then, shut up and get back to work.

I’m usually not one for movie quotations, but I’m considering adopting one as my mantra. “Fuck the bozos!”

Tags: , , ,

Martial arts pedagogy: first success: stances

One thing I’ve noticed with most martial arts students is that their stances are pretty poor. Learning stances is definitely a hard thing to do; it takes a lot of practice before you can just step right into a perfect stance. However, it’s important. Every one of the phenominal martial artists I’ve had the pleasure of knowing agrees: if your stances are bad, your motion will be bad.
For the first three lessons I taught, I took this idea to heart and focused a lot on them.

Today was review, and while they were still struggling with it, those three lessons were enough to get them thinking about it. As they completed each movement, I saw them going through a short “where are my feet?” stage. The number of times I had to remind them to think about it was pretty low. Though they’re still rough, the stances themselves are starting to look reasonably decent too. It took a week to get their feet looking like an average yellow belt at my school. This is effectively 6 months of progress in just 7 days! It might just be because this group is particularly intelligent and motivated, but I can honestly say I’ve never seen results like this before.

This may not be too applicable to a commercial school. Stances take a lot of practice, and the first few lessons (especially if it’s a “free trial” like most schools give) can’t be too frustrating. However, given the results I’ve seen over the last week, if you have the option, stress stances more than anything for the first several lessons. Some examples of things I did:

  • When practicing kicks with a pad, have the student check their stance before and after each kick.
  • Once they get the basic mechanics of a kick, have them look down at their feet during the placement phase.
  • In a self-defense technique (American Kenpo’s kumite), have the student stop after each move, tell you what stance they’re supposed to be in, then have them check it.

Of course, looking at the feet constantly is a bad habit, and I’m hoping they’ll get the feel for it pretty quickly, after which I will ask them to work at not looking at their feet. I haven’t yet taught them any forms, but I think the same kind of thing is applicable there.

My goal is to have great stances in just a month’s time. If this happens, I’ll be well on my way towards my previous 18-months-in-6 goal. Woo!


Martial arts pedagogy

About a week ago, I began teaching Kenpo to a small group of friends. A couple of them have been asking about it for a while, and we finally got it all organized. It’s great fun, and they’re proving to be better students than I could have ever asked for.

After teaching a couple lessons, I decided to look for information on martial arts pedagogy. After all, there are a lot of martial arts teachers out there, and there’s got to be some good information out there on how to teach, right? Apparently not.

Quick searches for pedagogy information for my other two fields (computer science and music) both turn up millions of results. The first several pages of results for both of these are full of excellent information. The same search for martial arts turns up only a few thousand, and none of them are useful. Why is this? I don’t think your average computer science teacher is any more dedicated to his students than your average martial arts teacher. In fact, the vast majority of martial arts instructors I’ve met have been incredibly devoted to their students, whereas most computer science professors would have a hard time caring less.

Most of the information I did find started with the suggestion that tradition is important, and you should teach like your instructor taught. While there’s a lot of history in the martial arts, I doubt most people teach the same way people hundreds of years ago taught; every teacher along the way makes their own changes, and the realities of trying to pay the bills by teaching martial arts dictate that some things just shouldn’t be done. Running an MA school is not a good way to make money, and every training technique that drives away a student is a liability.

While I do agree that tradition is important, I think there’s a lot of progress still to be made. People have had great success “taking computer science out of the lecture hall.” While MA is a lot more hands-on (shame on me) than CS, I do believe that there’s got to be better ways to do some things. At my Kenpo school, a dedicated student can become a pretty decent 1st degree black belt in about 5 years. Can the same results be gained in 4? Maybe even 2 or 3? I honestly don’t know.

But I want to find out. I’m going to experiment with teaching methods, and I’m going to blog about it. I have these students for 6 months before I move to California to join the VMware world-domination machine. After those 6 months, my goal is to have them move like they’ve been at it for 12, maybe even 18 months. If I discover something, and these posts show up on the results page the next time a budding instructor looks, it will have been completely worth it.


A big web of data

I just spent about 30 minutes entering links into wordpress. It’s something I’ve been meaning to do for a while. As I was nearing the end of this process, I began to realize something.

A visitor to this humble page would get not only my ramblings, but links to a fair number of my friends’ journals, my bookmarks, my CIA stats and my photos. Along with all of these, they also get RSS for everything. This is a staggering amount of information, and there’s got to be something cool that can be done with it.

I’m starting to toy with the idea of a web service that would take a page, parse out links, follow things with proper XFN relationship tags and…err…do something with all that. Probably nothing will come of it (given my current projects situation), but it’s an idea that’s so tickly that it just might happen.

Tags: , , ,



Tags: ,