Archive for September, 2004

The second strip and already an in-joke

Dalbert

Ah, mercy… I just can’t help myself. Be sure to see previous [first ever] Dalbert comic to understand this one.

The Seminal Adventures of…

Dalbert

Upsampling in Photoshop

The nice thing about writing a quasi-technical blog is that I can be as vague as I want when it comes to details, proofs, formulae etc. So when I want to write about some interesting algorithm or whatever, I only have to investigate it as far as it suits me to, and then I can just get distracted and think about something else… like sausages… So anyhow, let’s get [quasi] technical about image processing! Yay!

Photoshop is an interesting tool, especially if you take the word interesting to mean “not nearly as useful and powerful as it should be, considering its maturity”. One of the things that Photoshop [along with every other image processing tool in the universe] will often be used for is upsampling. Upsampling is the thing where you resize a small image to a bigger one, interpolating extra pixels in the process.

The image to the right attempts to illustrate the three different types of upsampling available in Photoshop [v6.0]. The left column shows the 8 original pixel values. From these the middle column was created using bilinear interpolation and the right hand one using bicubic interpolation.

By default, upsampling is done using bicubic interpolation and everyone [including me] assumes that it’s the best for photos and continuous tone images, but this is not necessarily the case.

Problem #1: A steadily changing series of samples get bicubically interpolated in such a way as to introduce corrugations which should not be there! The following 3 figures illustrate this effect perfectly.


no interpolation


bilinear


bicubic

Problem #2: Bicubically interpolated pixel values can be beyond the range of the original image, resulting in an overall sharpening effect, and in some cases clipping [where solid patches in the final image turn out either totally black or totally white]


no interpolation


bilinear


bicubic

What’s actually going on with the first problem I can’t say for sure [cubic interpolations of continuous samples do not normally wobble], but I suspect the second problem may provide a clue; a straight cubic function applied to sample data will tend to overshoot the source range quite a lot, and it possible that the attempt to mitigate the second problem has effectively introduced the first.

Regardless of the hows and whys – which maybe I’ll look at in more detail sometime – bicubic interpolation is NOT always better, even if it’s smoothness you’re after. The humble no-fuss bilinear will often serve you best.

“Cringe is the new horror”

Further to last week’s riveting cringe story, I thought I should post a link to a fantastic episode of This American Life, a public radio show which I and several friends listen to almost religiously – which might seem strange given that we all live on the other side of the world in Australia. The show is just that good.

… A lot of stories from your life, the more you tell them, the less power they have over you. But cringe stories often don’t seem to lose their power over time. Every time you remember, you cringe…

You’ll find a synopsis and a RealAudio link to the Cringe episode on this page [and yes I know that RealPlayer sucks balls, but it’s better than nothing]

The Big Cringe

So here is a totally true story, which just happened:

‘Twas Friday night [a few hours ago], and more specifically the end of a pretty ordinary day for yours truly; You know the kind of day where you′re always a beat behind, and every time you try to start a conversation no one hears you properly… except when you say something stupid of course.

I was returning from one of my long walks – walking being a recently acquired habit and sort of a last-ditch attempt to stave off muscular atrophy. It was about 9:30PM and although I was following a major road there were no other pedestrians around.

Except that is for the person whose footsteps I could hear some small way behind me.

I walked on for a few minutes, and the footsteps seemed to keep pace with mine – something I found a little disconcerting – so to break the pattern I crossed the road, thereby giving my anonymous tailgater a chance to pass without having to come shoulder to shoulder.

Not because I was scared or anything – Just so we′re clear on that. Stopping to cross was also a handy way of stealing a casual glance, although all I could really see was a fairly thin figure in a tracksuit and a beanie.

Switching to the present tense now, just to make things more exciting.

So there I am, walking along, happily unaccompanied once again. Some time goes by, then I happen to glance across the road and notice that the track-suited figure is no longer there. Odd. At first I assume maybe they′ve stopped at one of the houses on that side, or just turned down a side street. But no, they′ve decided to cross the road too, and are walking right behind me again! So hey, that′s cool, no big deal I′m thinking, I′m not intimidated. It′s a free country, people can walk where they want.

I come to a side-street crossing and decide to stop, even though there′s no need, since it′s night time and the road is clear. The stranger catches up, and then stops just behind me! So now this person is just standing there with me, on a corner, with no traffic, for no good reason. I have to get a better look, if only for the police description. Glancing “casually” over my shoulder I catch a glimpse of a face…

And it′s a girl! Oh thank God, it′s a girl!

Not that I was scared or anything – Just so we′re clear on that.

So now I just kind of start walking across the side-street, which makes my stopping in the first place look a bit strange since the road is pretty quiet and the crossing has been clear the whole time we were standing there. And this strange girl follows right on behind again.

After striding briskly for another few minutes, I can′t help noticing that she is still keeping pace with me. There′s no one else around, and it′s creeping me out again, because it really feels like she′s deliberately staying on my tail. How long can we keep this up? I′m already at my maximum walking speed and I can′t seem to get ahead, so why didn′t she pass me earlier when she had the chance?

Before long I decide I just can′t stand the suspense anymore; I am so acutely conscious of her walking just behind me that I am no longer certain whether it is I who am struggling to stay ahead or she who is struggling to keep up. I want to not be in front anymore, but I can′t cross the street again, that would be stupid!

So what I do is this [and this is the cringe bit]: I slow down rather abruptly, and in a totally misguided attempt to make this seem like not an alarming thing to do, I turn to her and say:

“Um, sorry, did you want to walk in front? You′re just right behind me there and… um…”

At which she looks really, really, really offended. And she replies “Hey I′m just walking in this direction OK?”

“Oh hey, I know, it just feels strange you know… walking together…” I trail off, realizing that the more I speak, the lamer I sound.

“Don′t worry” she says, the appalled look on her face communicating so much more than her words, “I′m not going to jump you or anything…”

“I′m sorry, I didn′t mean… I mean…”

“Look, no weapons!” she says, holding her arms out as she passes. And then she turns and keeps walking. Only slightly faster than me.

So now I just have to watch her very slowly recede in front of me, wishing oh-so-very-hard that there was something I could do to make myself feel less like a complete loser. For about the next five minutes she is still well within earshot, but it just doesn′t seem appropriate to try to start up a fresh conversation with her back. Ten minutes later I can see her up ahead sitting down at a bus stop, near where I turn off for my place. As I approach I′m thinking, I must say something cool… I will say something cool…

“Ermm…” I say quietly, just as she turns away and starts rummaging through her bag. She doesn′t seem to hear me, and so I just keep walking, and you know, it′s probably for the best.