Monthly Archives: August 2006

ImageMagick Examples

While surfing, I stumbled upon this page of ImageMagick v6 Examples. It’s kind of strange, but I still do a rather large amounts of image manipulation with command line tools (usually the netpbm utilities, mostly because they have been around forever. For some reason, I never really started using ImageMagick, but that’s probably a mistake: it has lots of nice capabilities, and this page helps highlight some of them.

[tags]ImageMagick,Image Processing,Graphics[/tags]

Add Another Core for Faster Graphics

Lately, Intel has been trying to promote the idea that with the advent of multiple processor cores on their machines, raytracing computer graphics scene in real time will not only become feasible, but perhaps the preferred way of rendering graphics for applications such as games.

I must admit, I’ve found some of their work to be rather interesting. Ingo Wald showed me that most of the performance issues that I sorted through almost 20 years ago when I wrote my first raytracer really are kind of questionable when applied to todays heavily pipelined, slow memory, SIMD machines of today. Indeed, the performance that I get from my toy raytracer that I wrote about five years ago is probably an order of magnitude or more slower than the best codes he’s managed to code up.

But still, I think they are quite a ways off if you talk about them replacing traditional GPU style rendering. The demonstrations that we see of RT raytracing are impressive technically, but typically lack much of the features that we’ve come to expect in game graphics. Images are typically poorly antialiased. Shadows are often sharp, being computed from single ray samples. There doesn’t seem to be a good solution for animating objects. Texture filtering is often poor. And doubling the resolution in X and Y typically
increases the work (and decreases the frame rate) by a factor of four. In short, there just seems to be a lot to figure out still.

Addendum: I was thinking about this because I got sent a link to a discussion on Slashdot. This reply voices some of the same concern.

You know, I don’t read Slashdot anymore. I didn’t actually make a conscious choice to do so, it just seems like there is seldom anything being discussed there of interest. Has anyone else abandoned Slashdot (not out of principle, but just because it isn’t that good)?

Addendum2: Oh, and this paper (PDF) from Intel talks about effects such as ambient occlusion, and illustrates it with a picture from Pixar’s Monster’s Inc. The only problem: we didn’t actually use raytracing and ambient occlusion on Monsters Inc.

Addendum3: The San Jose Mercury News has a relevant article on the chess game that the CPU and GPU manufacturers are playing to try to position themselves in this new, bold, all raytracing world.

Addendum4: Wayne and Julian informed me that indeed, the image that is presented in the Intel paper above does have ambient occlusion in it. It was a special one-off that they did for their own SIGGRAPH paper, and used models from Monsters Inc. but never appeared in the movie. The 2003 Copyright date should have tipped me off.

[tags]Ray Tracing,GPU,Computer Graphics[/tags]

Estaban Loaiza, I apologize…

I’ll admit it, I was giving Oakland Athletics pitcher Esteban Loaiza a hard time. I can’t say it was totally undeserved. In the month of July, Loiaza pitched 22.4 innings, and allowed 20 earned runs, for an ERA around 8.0. But in August, he’s a new man! He’s pitched 34.4 innings, and allowed only 7 runs, for an ERA of 1.8 in the month, not including tonight’s shutout effort against the Red Sox.

Keep up the good work Esteban!

Addendum: Adam Melhuese just hit a pinch hit homerun in the bottom of the eight to give the Athletics a 9-0 win lead (sorry, I was premature) win (it’s final now) against the Red Sox.

[tags]Baseball,Oakland Athletics, Loaiza[/tags]

LibriVox

I was reminded recently of the existance of LibriVox: a site in which volunteeers read books and shorter works and creates public domain audio books out of them. There are now 117 completed books in their catalog, including one of my childhood favorites, The Wind in the Willows by Kenneth Grahame, in no less than two separate recordings. Lots of good fodder for your cheap $40 MP3 player.

Addendum: I have on a couple of occasions plugged the human read versions of The Adventures of Sherlock Holmes on Project Gutenberg. For some reason, the 32kpbs version of that work didn’t agree with my new little MP3 player. In the middle of many of them, they would simply skip to the end. The 16kbps versions didn’t have this problem.

Microsoft Rant of the Day….

While putting in a dozen miles on the stationary bike, I was reading my blogs on my LG CU500, and found Robert Scoble’s post on the startup sound in Microsoft Vista. Apparently the plan for Vista is to have a mandatory, unchanging startup sound to greet you whenever you power on your computer.

All I can say is “WTF?” What is the rationale for dictating something to your users like this?

Scoble lists two reasons:

A spiritual side of the branding experience. A short, brief, positive confirmation that your machine is now concious and ready to react. You can turn on your Vista machine, go eat some cereal, while your machine is cold booting and then this gentle sound will come out telling you that you can log in. You won’t need to wait for your machine to startup, he says.

I have a different idea: how about working toward creating a system which you don’t need to wait for because it actually starts immediately when you power it on? You won’t need the short, brief, postive confirmation, you’ll just turn on your computer and start using it. That would be a positive branding experience.

Volume control in a Windows machine is a wild west. A mess. The startup sound is designed to help you calibrate or fix something that got out of wack when you startup your machine. Let’s say you muted your machine, and you don’t hear your startup sound, you know you aren’t ready to listen to stuff. The Xbox has a hard-wired startup sound. There is one way to mute it: to turn down the speakers that are connected to your Xbox. Same will be true for Windows Vista.

So, let me get this straight. You think that volume control is a mess, so your solution is to make it mandatory that someone experience a sound which is almost certainly set to the wrong level every single time they start their computer?.

I frequently use laptops in libraries or other public areas where all the beeps, startups and audio confirmations can be disturbing to the people around me. I use my laptop in my living room while watching TV with my wife (who often is typing on her own laptop). Mandatory sounds in that arena are also annoying.

But here’s the real thing: Scoble says “I can see this from both sides.” Well, that’s good, then the answer is really quite obvious:

You set the default startup sound to be something. You allow the user to change or disable it.

Honestly, is there even one user anywhere who asked you to choose a startup sound for them and hardwire it so you couldn’t turn it off? I understand how your market research guys might want you to do that, in some vain hope of creating “positive user experience”, but I’d hope that you’d do that by making a fast, robust, useful and even fun product. DIctating something even as trivial as this to your users simply to serve as advertising for yourself is just silly.

[tags]Microsoft,Rants and Raves[/tags]

Cheap Gadget: Sandisk Sansa m230

I’ve been trying to get back into exercising at the gym more, which is always a time of intense boredom. I’ve brought my Axim x50v to the gym and used it to listen to podcasts, and my relatively new LG CU500 also works as a pretty good MP3 player, but I thought it might be nice to have a cheap, even lighter device to satisfy my need for amusement while I’m cranking out the mileage on the treadmill.

Sandisk Sansa m230

A quick trip to Best Buy revealed a $40 MP3 player with 512M of memory (enough for my rather modest needs). It’s the Sandisk Sansa m230, a not overly cute but reasonable mp3 player at a near disposeable price. Even at this price point, I wanted a couple of features:

  • Display, with backlight. My wife has an iPod Shuffle, which is fine as far as it goes, but the lack of display (as well as the increased price) made it a deal breaker for me.
  • Reasonable amount of storage (512M is reasonable).
  • Easy “hard disk” interface. I don’t use iTunes, don’t care to use iTunes. I just want to drag music files onto it, and have it work. It does.
  • Fast USB 2.0 interface. Life is too short for USB 1.1
  • Powered by a single AAA battery

The long and the short of it? It’s got all those features. It even throws in a voice recorder and an FM radio (the FM radio doesn’t appear to be very sensitive, but it’s a nice bonus). The build quality isn’t stellar, but it’s pretty reasonable. At $40, it’s a pretty neat gadget.

[tags]Gadgets,Sansa m230,MP3 Player[/tags]

On a similar note, e

Yesterday I wrote a simple program in C to compute pi to a useless number of decimal positions. A few minutes of thought told me that I could use the bignum support in Python to write an even simpler program. It was true: it took me maybe three minutes write the program to spit out π (and under a second to run). To repeat the output would be boring though, so I just took another thirty seconds and converted it to compute e instead. Here’s 1000 digits of that:

2.

7182818284 5904523536 0287471352 6624977572 4709369995
9574966967 6277240766 3035354759 4571382178 5251664274
2746639193 2003059921 8174135966 2904357290 0334295260
5956307381 3232862794 3490763233 8298807531 9525101901
1573834187 9307021540 8914993488 4167509244 7614606680
8226480016 8477411853 7423454424 3710753907 7744992069
5517027618 3860626133 1384583000 7520449338 2656029760
6737113200 7093287091 2744374704 7230696977 2093101416
9283681902 5515108657 4637721112 5238978442 5056953696
7707854499 6996794686 4454905987 9316368892 3009879312
7736178215 4249992295 7635148220 8269895193 6680331825
2886939849 6465105820 9392398294 8879332036 2509443117
3012381970 6841614039 7019837679 3206832823 7646480429
5311802328 7825098194 5581530175 6717361332 0698112509
9618188159 3041690351 5988885193 4580727386 6738589422
8792284998 9208680582 5749279610 4841984443 6346324496
8487560233 6248270419 7862320900 2160990235 3043699418
4914631409 3431738143 6405462531 5209618369 0888707016
7683964243 7814059271 4563549061 3031072085 1038375051
0115747704 1718986106 8739696552 1267154688 9570350354

[tags]Mathematics[/tags]

Fixing an annoyance with the CU500

LG CU500 Cell PhoneI mostly like my new LG CU500, although, like many gadgets, it’s not without its annoyances. For instance, the builtin WAP web browser is just, well, pathetic. It isn’t very powerful, and crashes horribly when loading larger pages. Yuck. Luckily, it’s got Java, so you can just download the minibrowser from Opera.com and you are back in business. Well, you would be, except that the LG CU500 has an annoying bug where it will ask you for permission to access the web every single time. Sigh. Luckily, somebody seems to have figured this out, at least if you have the LG USB cable (I don’t yet, but will soon).

Check out the following on howardforums.com:

vB Easy Archive – CU500 remove Java permission prompt how-to

[tags]Cell Phones,LG CU500,Java[/tags]

Take that, William Shanks!

Every once in a while, I get the urge to write a program for the sheer fun of it. I wrote my first (and second, and third) raytracer just for fun. I’d like to write a chess playing program just for fun. I’ve written some chunks of programs that have to do with evolutionary computation just for fun. Some are big projects, and may never get done. Some are small.

One of the small programs I thought I might try to write would be one to calculate pi to arbitrary (or relatively arbitrary) numbers of digits. An hour later, I have a program which spits out the following:

3.

1415926535 8979323846 2643383279 5028841971 6939937510
5820974944 5923078164 0628620899 8628034825 3421170679
8214808651 3282306647 0938446095 5058223172 5359408128
4811174502 8410270193 8521105559 6446229489 5493038196
4428810975 6659334461 2847564823 3786783165 2712019091
4564856692 3460348610 4543266482 1339360726 0249141273
7245870066 0631558817 4881520920 9628292540 9171536436
7892590360 0113305305 4882046652 1384146951 9415116094
3305727036 5759591953 0921861173 8193261179 3105118548
0744623799 6274956735 1885752724 8912279381 8301194912
9833673362 4406566430 8602139494 6395224737 1907021798
6094370277 0539217176 2931767523 8467481846 7669405132
0005681271 4526356082 7785771342 7577896091 7363717872
1468440901 2249534301 4654958537 1050792279 6892589235
4201995611 2129021960 8640344181 5981362977 4771309960
5187072113 4999999837 2978049951 0597317328 1609631859
5024459455 3469083026 4252230825 3344685035 2619311881
7101000313 7838752886 5875332083 8142061717 7669147303
5982534904 2875546873 1159562863 8823537875 9375195778
1857780532 1712268066 1300192787 6611195909 2164201989

William Shanks spent his entire life computing pi to 707 decimal digits. Unfortunately, he made a mistake 527 digits in, and the rest were hopelessly screwed up as a result. Now, a hundred plus years later, redoing the calculation takes an hour of my time, and about two seconds of computer time. That’s what Moore’s Law has done for humanity: a century ago, to compute this would have been the work of a lifetime. Now, it’s just a coffee break. Oh, and by tomorrow I’ll have pi to a million digits (and the program I wrote is laughably inefficient, we could obviously do much, much better).

[tags]Mathematics,Pi[/tags]

Zombies Invade San Francisco!

Rats, I missed the zombie attack that happened in San Francisco yesterday. I was gonna go down there and snap some pictures, but life intervened, and my documentation of the existance of the undead got pushed back behind the mundane acts of exercising, mowing the lawn, and doing grocery shopping. Man, am I lame. Oh well, in honor of the event, I’ll unveil my new banner for the top of the blog. What do you think?

[tags]Zombies[/tags]

Pathological Programming in SNUSP

I have a pretty keen interest in programming languages, and sometimes this leads me to esoteric or even perverse extremes. For instance, I had fun with brainfuck for a while, even writing a compiler for the language that fit in my .signature file:

#define P(C,X)case C:printf(#X);break; /* bftoc.c by markv@pixar.com */
main(){int c;printf("char a[9999];main(){char*p=a;");while((c=getchar())>=0)
{switch(c){P(62,p++;)P(60,p--;)P(43,++*p;)P(45,--*p;)P(46,putchar(*p);)P(44,
*p=getchar();)P(91,while(*p){)P(93,});}}printf("exit(0);}");exit(0);}

For an interesting complication of this idea, surf on over to the Good Math, Bad Math blog and check out
Pathological Programming in SNUSP. It’s… well, I think it’s pretty cool.

[tags]Brainfuck,SNUSP,Good Math,Esoteric Programming Languages[/tags]

Addendum: I coded up a SNUSP interpreter in about an hour, which draws the program on the screen and animates the position of the program counter using curses. It’s kind of interesting to watch programs execute, particularly the Ackerman’s function, which has the unique attribute of somtimes executing loops in a clockwise direction, and other times executing them in the reverse direction.

Ripping 3gp Video with FFMPEG

I admit that I was spoiled to a certain degree by my old Motorola mpx220 smartphone: it would play windows media files, and with the addition of the TCPMP media player, many other formats as well. My new LG phone only plays 3gp video, and I hadn’t ever bothered trying to rip video to that format before.

I rapidly discovered that while the stock version of ffmpeg that I had would handle the video, the AMR audio codecs weren’t built in. So, I went over to my Ubuntu box, and entered:

sudo apt-get source ffmpeg

If you cd down into the libavcodec directory, you can read the code to amr.c, which will tell you how to fetch the code you need. You only really need the amr_float code. Unzip it like they say, and then add --enable-amr_nb to the options that you use when you configure. Then just make as normal. It wasn’t difficult at all.

The commandline you pass ffmpeg will probably look something like:


ffmpeg -i bbq.mpg -s qcif -r 10 -b 56 -ab 16 -ar 8000 -ac 1 bbq.3gp

Here’s the resulting video file, which you could test on your phone. I’m not sure the audio sync is exactly right, but it’s not terrible either.

[tags]Mobile Phone,Mobile Media,Video Encoding, FFMPEG[/tags]