Cautionary tale: domain renewal and hoop-jumping

Site didn’t exist for a few hours this morning.  Reason: I didn’t renew my domain.

Except I did.

Except, well, I didn’t.

The final step in the process of making a payment to my registrar is clicking on a button that launches a popup that allows me to do some authentication with my credit card company.  This is presumably for my own protection—or at least for theirs—but it happens after all the normal steps I associate with e-commerce, and there are no blinking red lights to remind me that I have to do another thing.  Which is frustrating when it’s a very important thing, too.

Still, I’m happy that everything is back so quickly.  I was worried about a couple days of downtime, but everything seems to be back to normal with maybe an hour of when I first realized I had a problem.  Whew!

Hello, traffic.

I haven’t looked yet, but I’m guessing I just got a lot of eyes on the Retro-Histro entry below, judging from (a) the spiking unresponsiveness of WP, and (b) what was just going on in top:

top - 09:35:28 up 1 day, 21 min, 3 users, load average: 422.96, 371.06, 201.4
Tasks: 41 total, 27 running, 14 sleeping, 0 stopped, 0 zombie
Cpu(s): 75.6% user, 24.1% system, 0.0% nice, 0.3% idle
Mem: 4075060k total, 3737756k used, 337304k free, 6436k buffers
Swap: 6313512k total, 681624k used, 5631888k free, 221112k cached
31862 jmillard 15 0 12504 12m 4984 R 1.0 0.3 0:00.29 php5.cgi
26728 jmillard 15 0 13316 13m 5264 R 1.0 0.3 0:00.28 php5.cgi
7088 jmillard 15 0 13312 12m 5264 R 1.0 0.3 0:00.26 php5.cgi
27222 jmillard 15 0 13304 12m 5264 R 1.0 0.3 0:00.29 php5.cgi
28867 jmillard 15 0 13300 12m 5264 R 1.0 0.3 0:00.28 php5.cgi
31694 jmillard 15 0 13312 12m 5264 R 1.0 0.3 0:00.28 php5.cgi
21168 jmillard 15 0 13300 12m 5264 R 1.0 0.3 0:00.26 php5.cgi
26186 jmillard 15 0 8108 8104 4784 R 1.0 0.2 0:00.07 php5.cgi
6814 jmillard 15 0 13304 12m 5264 R 0.7 0.3 0:00.34 php5.cgi
13302 jmillard 14 0 13400 13m 5032 R 0.7 0.3 0:00.32 php5.cgi
6369 jmillard 15 0 13320 13m 5264 R 0.7 0.3 0:00.28 php5.cgi
31506 jmillard 15 0 13312 12m 5264 R 0.7 0.3 0:00.27 php5.cgi
13190 jmillard 15 0 13308 12m 5264 R 0.7 0.3 0:00.28 php5.cgi
14985 jmillard 15 0 13320 13m 5264 R 0.7 0.3 0:00.28 php5.cgi
17675 jmillard 15 0 13308 12m 5264 R 0.7 0.3 0:00.27 php5.cgi
28108 jmillard 15 0 13320 13m 5264 R 0.7 0.3 0:00.30 php5.cgi
4159 jmillard 15 0 13320 13m 5264 R 0.7 0.3 0:00.31 php5.cgi

Heh. Hi, folks! Melt that dreamhost server!

Retro-Histo: making an image fit your histogram!

So David over at Ironic Sans recently rolled out a neat trick: starting with a histogram and working backwards, as it were, to create an image that fit it.

Wonderful idea. And he does it; but he doesn’t take it far enough, dammit. His output works—its histogram, when viewed, is indeed the NYC skyline—but the image itself is just a spiffed-up greyscale gradient.

What about being able to create an arbitrary image—or, more to the point, being able to modify an existing image—so that you come away with something that looks like something and fits your target histogram?

Sure! I’ve been working out the idea for the last few days (not that it’s a days-long problem, difficulty-wise, but I’ve been coming at it slowly here and there), and I’ve got a perl script that will take a histogram and a source image and spit out a new image that is undeniably the “original”, but modified in its brightness levels to make it fit the target histogram.

Example time! Here’s a source image: a picture I took a while back of a firehand in Portland.

original firehand image

And here is that image’s original histogram:

firehand histogram

Now, that’s a fine histogram and all, but what I really want is an image that has this histogram—the skyline of Miami. (Why Miami? I’ll get there in a minute, don’t worry.)

miami skyline histogram

So, okay: I run this through my histogramization script (basically some straightforward Perl using Image::Magick for image-reading and -writing routines), and what I get out is this:

retrohisto'd firehand

Hey, it’s the original image, but kind more dark and grainy. And with a histogram that looks like the Miami skyline.

Hell yes. Of course, you’ll have to check it in photoshop or whatever to actually see the proof, but if you’re reading this you’re probably the sort who would do that. Go crazy!

But wait! David was originally playing with the idea of an image that was its own histogram. He got a nice approximation with a smooth, abstract curve and left it at that. But I’ve got the tools now to do better. So:Here’s a picture of the Miami skyline snagged (woo, creative commons!) from flickr, made greyscale, resized and cropped down to fit our 256*100 histogram image size.

miami original

Here’s that image’s histogram, for reference:

original histogram

Here’s that Miami skyline-histogram from above again: I made it by painting the city black and the sky white in Photoshop.

miami histogram

And, shucked through the Perl script, here’s what came out the other side:

miami skyline with a self-similar histogram

Again, you’ll have to check the histogram in your viewer of choice to be sure, but that right there is a picture of the Miami skyline with a self-similar histogram. Hot damn.

So! It can be done. There are a lot of wrinkles, of course—for one, this method produces stranger results for very eccentric histograms; for another, it’s only greyscale, color being a bit more complicated of an issue (though not necessarily fundamentally so, depending on how you handle it). The way one histogram viewer or another displays a given image will also affect the quality of the histogram-viewing experience, so what looks good to in the histograms this script itself generates won’t necessarily look great in photoshop or the GIMP or whatever—the shape should be right, but it might be a bit jaggy or have the wrong aspect ratio. Some of that is probably solvable, but I’m not going to try at this point.More images, histograms, and the perl itself can be found in the working directory.

Suggestions, comments, questions &c are welcome, as are custom histograms if you’d like me to see what they do to images. If you want to send me a histogram, it needs to fit these parameters:
– 256*100 pixels
– black and white, black on the bottom
– at least one black pixel for each level (this is fragile alpha software)

Nerd fun is the best goddam fun there is.

Late Update! Here’s what happens if I give this a shot with the original NYC skyline shot that David used for his experiment.

Original (cropped down to histo-size to improve the self-similarity results):

Histogram of original:

Target NYC histogram

And the output, with target histogram:

Cool! It’s kind of ugly, though; I mentioned above that one caveat of this technique is that more eccentric histograms will produce odder results, and this is a decent example. The original image has a great big spike of dark tones (the skyline silhouette is a wash of black (or something close to black, really) and the target histogram has a somewhat well-distributed range of tones, which means that by mathematical necessity that skyline will have several varied tones filling out the even dark space of the original.

It’s also jpeg artifact theater, hoo boy.

So, lesson learned: a good range of tones in the original will improve output in the final image, generally speaking. Compare with the self-similar Miami output above—that photo had a pretty rich palette to begin with, so it came out looking more over-processed than ugly.