Dithering?

Jussi Hagman from Finland writes:

I was just left wondnering whether the 18-bit test image should have
been dithered, the display manufacturers could perhaps use some kind of HW based dithering to give an illusion of a better color depth.

Good question, and if I get the time I’ll do a follow-up on exactly that issue.

I started by looking at my brother’s PowerBook, where he did a quick test gradient in Illustrator. We saw banding on the machine, so it looked 18-bit, not dithered.

I’ve since started to question this initial test, since everyone seems to report that their computer looks fine. Adobe has a long history of doing things their way, and it’s possible that Illustrator is 18-bit on an allegedly 24-bit laptop.

At some point, time permitting, I hope to post an 18-bit dithered test image. I’ve done a quick test on my desktop (Ubuntu Linux with a generic desktop LCD) which makes me suspect that hardware manufacturers are doing built-in dithering. But I’ll need a better test image to be sure.

How good is your color?

There’s a bit of a hubbub about the colors on Apple laptops. It seems they’ve been claiming to display millions of colors, but the LCD displays only support 8 bits of color. There has been a lot of talk about technical means to tell how good your color is, but none of these get at the core issue: can you tell the difference?

So here are a few pictures which can help you determine the visible quality of your display.

24-bit color test

Look at the 24-bit image first. If the colors look like a perfectly smooth gradation, you have a 24-bit display. If you see bands the size of the black bars, then your vision is better than a normal human’s. (Or so the conventional wisdom says.) If you see bands that are significantly wider than the black bars, then you probably have an 18-bit display, like the ones Apple apparently is using.

On 18-bit displays (6 bits each for red, green, and blue) the 24-bit color bands should look like the ones in the 18-bit test image. This is equivalent to the “thousands of colors” mode on Mac OS 9.

In case the color bands aren’t obvious in that image– which is typical in bright daylight and other adverse situations– here’s a 4-bit test image. Which brings up an important point: if you couldn’t see the color bands in the 18-bit image, you might want to turn out all the lights. Don’t do it right now, though, the after-images in your retina from looking at all these vertical lines will make you see bands where there aren’t any. That’s why I had you look at the 24-bit image first.

I haven’t tested this on any laptops yet, so it will be interesting to see what other people report. I can verify that my generic desktop 19-inch LCD is fully 24-bit. (I’m slightly red/green color blind, but that doesn’t matter for this test.)

So how did Apple come to be in the position of advertising 24-bit, but delivering 18-bit? This is pure speculation on my part, but here we go. Traditionally, laptop displays have been significantly worse than desktop displays. Desktops had bright cathode ray tubes (CRTs), while laptops had the most state-of-the-art liquid cristal displays (LCDs). State-of-the-art originally meant you could see beige-on-black, unless you were to one side, in which case you saw black-on-beige. Over the years LCDs have improved from awful to not so bad. My 7-year-old PowerBook has a slight greenish tinge, which you don’t notice unless it’s next to a better display. You wouldn’t notice the difference between 24-bit and 18-bit very easily on that.

It used to be that the video cards were the limiting factor in the color display, so once 24-bit cards became cheap, Apple started to discourage the use of the 18-bit color mode. From there, it became easy to forget that the laptop displays were still only 18-bit.

Assuming it really is 18-bit. Again, I haven’t tested it, but there are ways to cheat. Dithering across pixels (or sub-pixel, as some have suggested) won’t help in this case, but they could dither across time: you can cheat by flashing between two nearly-identical colors. If the LCD refresh is slow enough, the liquid crystal might actually remain between those colors– producing a real intermediate color. I’m skeptical that Apple would do this, since the LCD manufacturer has more interest in investing in these sorts of tricks, and I would suspect that true 8-bit-per-subpixel quality is easier for them to get at directly.

Ian is signing

It’s official. Ian has used sign language for “drink” and “more” (food). He also signs “more” in the mirror when I’m holding him, just for his own amusement–which doesn’t count. He’s actually communicating.

Signing is useful, not because it teaches language a little earlier, but because it allows us to communicate. I remember when Sylvia learned to sign, she let us know that she wanted that blue cup–the one she had just seen, not the identical one we tried to give her. Without language, we would have never known why she was crying. Signing keeps parental blood pressure low.

Ian is crawling well, he’s signing… Grandma Catherine is going to be really surprised when she gets back next week to see how much he has changed in the last three weeks.

Also on the topic of language, witness the power of storytelling. For the past few weeks, I’ve been getting Sylvia to let me brush her teeth by telling her a story about her whale toothbrush. The climax of the story is the whale saying, “little girl, little girl, may I brush your teeth?” (In the last few days, she’s been avoiding answering the whale’s question. I’ve had to add the threat of an ogre to the story. But we’re still way better off than the fussing and crying she was doing before.)

A trip to the emergency room

On Sunday after church, Sylvia didn’t want to go inside. She lay down on the driveway and refused to get up. So Jordan picked her up by the arm. Then she really started to cry. This isn’t unusual, so it took a while for us to realize that her crying was now from pain rather than defiance. We didn’t see any bruises or anything obvious, so we gave her some pain killer and hoped she’d get over it.

Several hours later it hadn’t diminished, so we called our doctor, who told us to go to the emergency room. She suspected it was nursemaid’s elbow, which is easy to fix, but is best taken care of quickly.

The triage nurse at the emergency room had the same opinion, as did the doctor when we eventually saw him. Popping the bone back into place didn’t take long, but it didn’t take on the first try, and after the second try it took a while for the pain to go away. In between, Sylvia got X-rays and Jordan got dinner. The worst of it was having to wait for so long. We left for the emergency room around 5:30 or 6:00, and Sylvia and I didn’t have dinner until 10:00.

If we have a few more trips to the emergency room, Sylvia will start to recognize how unusual Ian’s experience was.

“Memory foam” pillow causes sleep apnea?

On Saturday I took a nap. It didn’t feel restful, and I remember at least once gasping for air. For at least an hour afterward, I felt the need to take deep breaths. On Sunday I had the same experience, only I was alert enough at the end to notice that my chin was resting on my neck. (I don’t have a double-chin.) When I nap, I’ve been using Jordan’s new “memory foam” pillow. It is convex in the middle, so it mainly supports the neck, with only a little padding for the head. The “memory” part is that it shrinks with heat, leaving an impression wherever you touch it.

The problem is that after sleeping for a while, the “memory” means that the neck no longer has any support. The pillow seems to work fine for Jordan, but I’m not going to be borrowing it any more.

Crawling

Ian is crawling now. He started all of a sudden on Saturday afternoon at 5:25 PM. It takes him a minute to go a foot or two, but at this point he’ll be getting better fast. He’s had all the moves for a while, but Saturday is when he put them together in a coordinated attempt to move forward. I was at my parents’ house for dinner, while Jordan was making a side-trip to buy a new camera. She called me from the store, and Ian crawled while I was on the phone.

In other news, the weather has been incredible. We had a record snow storm earlier this month, but yesterday it was 81 degrees. We haven’t had a day in the 70s yet. I rode my bike to work yesterday. It’s less than five miles, and the traffic isn’t too bad. It’s as if someone flipped the switch from “winter” to “spring” and suddenly there are birds, butterflies, and green shoots. At night you can hear the rustle of grass coming up. (At least that’s my best guess for the early-spring rustle; there aren’t enough insects out, and it goes silent after less than a week.)

The vicious cycle of remote procedure call APIs

Lately I’ve been working with remote procedure calls (RPC). My experience is that they tend to be more trouble than they are worth, but I thought I’d give it another look. RPC is a way to program in which you write a program as if it were run on one computer, but some of the commands are run on a remote computer.

At its most basic level, RPC is just message passing. You send the message “what is 2+2?” to a computer, and you get back the message “4.” In fact, message passing is all computer networking ever is. Message passing isn’t hard, it simply doesn’t look like normal programming. So RPC decorates message passing to look better. And when you are working with complicated data, it can make life easier.

The problem is that there seems to be an inevitable slippery slope of feature creep, which ends up making RPC unusable. The cycle seems to be:

  1. Start with general-purpose network protocol du jour, sending messages from a client to a server.
  2. That’s not enough like regular programming, so add wrappers to let you send arbitrary commands to the server.
  3. Oh, and the server should be able to send commands back to the client.
  4. But wait! That’s not secure! Add security protocols.
  5. (Optional) We don’t want to be restricted to one programming language; make it multi-language.
  6. How do we know what the server can do? Let’s add a directory for finding services. Better yet, let’s add a directory for finding all servers– and maybe a directory for finding other directories!
  7. This is unusable. Let’s start over with the new general-purpose protocol du jour.

Case in point #1 CORBA. Before CORBA, you used specific protocols (FTP, SNMP, etc.) which could be coerced to trigger remote actions. Even today, you can unsubscribe from an email list by sending “unsubscribe” email to a particular address. If those weren’t good enough, you passed C structures (massaged to be network-safe) from a custom client to a custom server. Then CORBA came around, and over time it obtained all of the features listed above. To make it multi-language, the CORBA spec required you to name your commands commands so they looked funny in most languages but would work in every language. And most implementations were buggy and expensive. But the killer for CORBA was that it required ORBs (service directories) on specific ports, and those ports are blocked on firewalls by default. When I worked at Net Perceptions, we discovered that many of our customers couldn’t use our product because the IT department which controlled the firewall was five layers of management away.

The solution was to piggy-back on port 80, the web server port. That is, run RPC through a web server. Someone had recently written an article on how much easier RPC was if it was done as XML messages through a web server. And that’s exactly what we did. Worked like a charm.

Next thing you know, a committee was formed to standardize SOAP (Simple Object Access Protocol) for XML over RPC. Sun and Microsoft announced that Java and Windows would both support SOAP. Everyone joined the bandwagon. Pretty soon SOAP was just as unwieldy as CORBA. Talking to eBay from Java yields 700+ auto-generated classes!

The fact of the matter is that for most things you want to use RPC for you use (1) a server you write yourself talking to (2) a client you write yourself, with (3) a small set of commands, which are known in advance. Directory services are almost universally a boondoggle– yet they are nearly always a required part of the protocol. Multi-language support is rarely needed, and if you do need it, the easiest way to do it is through a simple, clear message protocol; RPC auto-translation of one language’s structures into another yields ugliness in both languages.

My prediction is that in the next iteration someone will discover that you can use AJAX for general-purpose RPC. The new protocol will use all the so-called Web 2.0 technologies, including RSS feeds. A committee will be called together to standardize mash-up-style RPC. JavaScript (ewww…) will be used for sending arbitrary commands hither and yon.

Side note:

I’ve just spent a week trying to coerce Java RMI (Remote Method Invocation) to do what I want. As RPC goes, it’s better than most. But there are a few special requests I need to make of it, each of which doubles the complexity. And now I’m at a pont where I’ll have to add a special security policy to the Java runtime, which just plain isn’t feasible for this project. I could do it, but it would make our web server far more fragile. That or spend another day or two learning the bowels of Java security. So I’m about to rip out all my new code and go back to a simple socket-based message passing protocol.

Praise kids for things they can change

This article suddenly made it clear why I’ve always been a B student, despite always being told I’m smart. I’ve never been able to find the motivation to study harder, and I never knew why. It turns out that being told that you are smart makes you more risk-averse, not less: studying is evidence that you’re not naturally smart.

The general rule, it seems, is that you should praise (or criticize) people for the things they can change. By taking pride in being hard working, you can enjoy the work rather than focus on the end result. When you focus on being smart, pretty, or naturally talented, you avoid anything that might disprove it.

The article also has lots of interesting nuggets, such as the fact that kids recognize when have a negative correlation with performance. In particular, when teachers feel free to criticize the top students while only praising the less-than-average, even young students interpret praise as criticism and criticism as praise.

Ian crawling?

He can’t sit up on his own, and he just started rolling over.  But last night he distinctly and repeatedly put his knee under his belly and moved forward.  Not exactly crawling, but it’s a little close for comfort… baby-proofing the house really needs to go into high gear now.