Wrapping up 2008
It’s that time of the year, where one reminisces, remembers, recalls, regrets, reflects, and other activities starting with re’s. I was going through the posts I wrote this year, and some of the posts made me react with “Huh, I wrote that?”, “What was I thinking?!” and other epic reactions. So here are some of the posts, and if I can remember them, the unsaid reasons for writing them.
The post on Fibonacci sequence and its relation to the golden ratio was quite popular. It still comes up in search results every now and then. The story of the thriving rabbit population came from a childhood encyclopedia (yes, I still have the entire set).
The barber paradox is one of my favourite concepts. I read about it when flipping through my university textbook on logic. Basically, if you hit a stumbling block in your logic, you might find that challenging your original assumption reveals the answer to the stumbling block.
In May 2008, I managed to dupe persuade Guy Kawasaki into including me in the Programming section of Alltop. That was awesome, since I was trying to improve awareness of my blog and the concept I’m pushing for (multi-disciplines). Getting listed helped.
I also created a new site called Ragnarok Code. It was meant to be a code playground for me. I do a lot of .NET work and I want to do some stuff that I can’t on this blog (though there are ways to get around my PHP problem…). Wanted to code something with Silverlight and I never really got to it… That said, check out the OpenStreetMap application by Philip. It’s totally awesome.
Then I tried my hand at mixing storytelling and puzzles with the Mind Trap series. I planned for 5 parts, but failed to find interesting puzzles to weave into the story. In the end, I only had 3.
Alas, the full story of our trapped hero Ryan may never be revealed…
I also started a mini-series dubbed “Please ConvertToEnglish()“. It’s a play on the .NET functions such as Convert.ToInt32() and so on. What I had in mind was to explain certain code or human behaviour (mainly because of code) in simple English. I don’t see an end to it, since I draw inspiration from what I encounter… *smile*
There’s something else that came up often in my search results: The puzzle on 7 points and 6 lines (and the 2nd solution with corrections from a reader, Eric).
Then came the first (known) hack attempt on my blog. It was targetting SQL Server, so I was safe… I think… That analysis involved the use of a few pieces of information.
I also had a visit from Raymond Chen for something I wrote about rotating a matrix, which is different from a rotation matrix. Read the proof by Mathew which is simpler than mine, and it even looks like what I would write on paper with all the subscripts and superscripts.
My next embarrassing public humiliation was when I asked for advice on field of view (FOV). I was called on my article by two people no less (thanks to David and Jason aka xero)… That article sprung up from a university assignment, and was one of those questions where I never really got an answer. Like the one on using pointer arithmetic instead of array syntax. Wait, I didn’t write about that one…
In October, I wrote what I think was my crowning achievement then, the article on the use of bilinear interpolation in image rotation. It required the combination of a few pieces of information to work:
- Knowledge of raster, Cartesian and polar coordinate systems
- Linear interpolation and as a corollary, bilinear interpolation
- The “direction” of assignment
Strangely, the post on the digital clock puzzle came up moderately frequently in search results. I guess a lot of people were stumped… Great answer by Steven, though I couldn’t award him any prizes. I’ll have to get my hands on some noteworthy gifts…
I also started to get involved in the Singapore social media slash blogging scene. Got to know some really nice people, and there were also a few programmers too!
Then I tackled the hitherto unimaginable math problem on swinging doors. It was interesting. It was spontaneous. It was … alright, I was a bit bored. I also made a major mistake while discussing that, which I corrected with another post. Talk about barber paradoxes…
I finally came to terms with the lengthy name of my blog, and shortened what I am to being a Polymer. I still want to publish something more on it, maybe a manifesto. Still collecting my thoughts on this…
And I was a guest in a Tech56 podcast, a local production about technology and general geeky stuff. I was also at their 100th episode celebration/podcast event.
On the topic of podcasts, I submitted a question which was answered in Stack Overflow podcast episode 33. I asked for an opinion on reducing costs (in a software business, since Jeff and Joel probably won’t know much about the industry of the company I’m working at). In summary, the answer was to stop worrying about reducing costs and start thinking about increasing value.
Recently, I talked about digital image processing. It was something I wanted to write about for a long time, but never really got down to it. I also didn’t do justice to the topic, and I originally planned for something more fleshed out. I’ll leave it as it is till I can’t stand it anymore and I’ll follow up on it. And that image processing course I took was one of the most interesting classes in my entire university life.
And that’s 2008 for me. Have fun with the rest of December, and I’ll see you next year.
Christmas equals Halloween
You might already know how Christmas is equal to Halloween. You don’t? Well, I came across this some time ago, and it took me a few moments to figure out how Christmas can be equal to Halloween. Now, let me prove to you the truthfulness of that statement.
We have Christmas on 25 December. Let’s put that here:
DEC 25
= 25 [let's focus on the day, ok?]
= 24 + 1 [it's obvious I know...]
= (8^1) * 3 + (8^0) * 1 [some fancy arithmetic]
= 31 [of base 8. Much easier to work with than base 3]
= OCT 31 [let's use the short form of octal]
Wait a minute, OCT 31 looks awfully familiar… Hey it’s Halloween, which falls on 31 October! Thus is Christmas equal to Halloween.
Q.E.D.
Alright, in case you’re not following, the “proof” transformed Christmas and Halloween into their date representations. The date representations happen to be of the form “base-short-form number”. So Christmas became decimal 25, and Halloween became octal 31.
Here’s a lesson to take away. Sometimes, the problem you’re working on is easier to solve when it’s transformed into another representation. For example, rotating an image is easier when you transform all the coordinates from raster to Cartesian to polar, and then rotate in polar coordinates. Or change a colour in RGB format into HSL, so you can change colour just by varying the “hue” part.
That’s it for now. Happy holidays!
Matching textures with heuristics
I was in my 4th year in university. The course was on digital image processing, touching on both theory and application in equal measure. There were only 3 students, including me.
The course was interesting, albeit mind-numbing when some of the equations march into the lecture. The programming assignments were more fun, since we got to apply the theories. One of them was a rotating-an-image assignment, which formed the basis of my bilinear interpolation code. That was fun.
There’s this assignment where the professor gave us a set of texture images as samples. I can’t remember how many there were, so let’s say there were 200 of them. Then he gave us, say, 50 images. The assignment was to match those 50 images with the controlled set of textures. All textures were greyscale to simplify the assignment.
The 50 unknowns didn’t match pixel for pixel with the controlled samples. But they were of the same texture. For example, the controlled samples had one of marbled floor. One of the unknown images was taken with that marble floor, but in a different position. Of course, the professor could have given us red herrings to match, but he said all 50 were taken from the sample set.
Then there’s the fact that he wanted to play with his new camera back then (he admitted to it), and took lots of pictures to give us as assignments… There was an assignment with a picture of a rubber ducky…
I can’t remember exactly all the tests I used to match the textures. What I did was come up with a theory/test, and compute that test for all the samples. Then I did the same thing for the unknown textures. Then I match the unknowns with the knowns. If they were within some threshold of acceptance, that unknown texture was deemed matched to the respective sample texture.
Basically, I’m matching the textures using heuristics.
One of the tests used histograms. Basically I charted from 0 to 255 the number of pixels with a specific greyscale value. Pure white pixels have a value of 255, and pure blacks have 0 value. Then I matched the unknowns with the samples using mean squared error. If the sample matched with the least error was less than some threshold I set, then that sample was the matched texture.
I had another test involving Fast Fourier Transforms (FFT). I think I discarded the complex values and matched the unknowns using the real values part.
There’s another test involving median filtering. The idea was to capture the groups of neighbouring pixels as some usable data. So instead of a 128 by 128 pixel sample, I reduced it to a 16 by 16 matrix. You know, this one’s a bit iffy… I can’t remember whether I actually did it, or I just came up with it writing this…
Anyway, there’s a test to capture “pattern” data. The histogram test involves all pixels. The median filter test (if I actually did one) cluster pixel information in groups. Let me see if I can explain this better…

In the image above, the top right corner has more black swirly thingies close together than other parts of the image. The histogram test cannot detect that the top right corner has more black. It can only detect how much black in total there is in the image. Positional information is lost. Hence the need for a pattern test.
The histogram test is objective. Test results are verifiable and repeatable. However, matching the unknown textures require that I set a threshold. This is where the tests become subjective. Who’s to say a particular threshold value is more accurate than another?
In the end, I think I had 5 or 6 tests, and gotten a 94 (or was it 96?) percent accuracy. I was tweaking my threshold values so I could yield higher accuracy rates. See how subjective those tests of mine were? *smile*
The programming language of choice was MATLAB (yes, Will?), as dictated by the professor. So everything was coded in MATLAB. Which was good, because I’d hate to implement FFT on my own…
There’s something else too. I weighted those test results. Say test A was supposedly more accurate than test B. Then I gave the results of test A more weight in my final calculation. Thus, roughly speaking, if 3 tests out of 6 say texture A was the one, then that’s the one. It could also mean 2 tests had more sway if both carried high weights, and the other 4 tests weren’t conclusive enough.
One of my classmates got higher accuracy rates (97 or 98 percent) than I did, no matter how much I tweaked threshold values and weights, no matter how many kinds of tests I added (or took out).
But here’s the thing, and I want you to note this. Given a larger sample size, and a different set of unknown textures to match, my set of tests might actually yield better results than those of that irritatingly smug classmate of mine.
Here’s another takeaway. No one test can conclusively confirm and match the unknowns (even with some error margin). It took a few tests working in concert to obtain a relatively high accuracy rate. Think about that.
Sign up now to get your free ebook of "How to self-publish an online magazine". Your email is kept confidential, and is used only to send information about the magazine.



Hi! I write about maths and programming and other topics of esoteric interest. I'm also the editor of the online magazine Singularity, and you can get the latest issue at the top (it's free!).
