Archive for November, 2006

Twenty eight

Today I am 28 years old. The past year had been particularly hard and I’d been thinking about it all of yesterday, and about all the good things that are part of my life.

I am still a child in many ways. I’ve been programming since I was 12 and my love for computation has made me learn many things. While I got good at programming, I never really grew up to handle everything else in life. I don’t regret it, but sometimes I pause and wonder. It is a world of tigers and dragons.

The last year was rough and in hindsight, the changes it forced were good and I am on much better ground than where I was in years. I am close to mum, and I’m close to my friends who are really friends, who really like me, who won’t stab me in the back to further their own interests. And I am gainfully employed at a good company.

Have you ever seen an inchworm reach out from the safety of a leaf into air to see what else it could climb on to, and then fall to the ground? If you think you are on shaky ground and are scared of exiting your situation for fear of falling, I say fall but do reach out. If you fall, atleast when you land you’ll be on flat ground and you’ll have something new to explore.

28 is a perfect number. I have learned some new things about life.

Those who speak know nothing
And find out to their cost
Like those who curse their luck in too many places
And those who fear are lost

I know that the spades are the swords of a soldier
I know that the clubs are weapons of war
I know that diamonds mean money for this art
But that's not the shape of my heart

Graphics Planet hackergotchis and Libre Graphics Meeting

Graphics Planet bloggers who haven’t got hackergotchis setup should send me theirs so I can put it up :) . Extra points for those who mixter it.

In case you haven’t heard, the next Libre Graphics Meeting is going to be held in Canada in May next year. If you’re intested in attending, please read the post at the second link and contact Louis Desjardins.

Rockin’ in the free world

Sun, you’ve rocked my day today by freeing the Java development kit as OpenJDK. Congratulations to all the people at Sun and outside who have lobbied hard for it and didn’t give up hope.

Java Duke rocking in the free world

Smooth smoothing :)

Following up on the last post, we now have smoother loglog smoothing, for the Fractal Explorer plug-in of GIMP. Mmmm. Will be committed after some cleanups of the plug-in code though.

Classic smoothing (or lack of it):
Mandelbrot set without smoothing

loglog smoothing:
Mandelbrot set with loglog smoothing

On finding bugs

I keep saying that cooking, unless one’s doing it for recreation, is crazy as one spends way too much time cooking and cleaning up than eating the result. Fixing bugs is something like this, but worse. It’s probably someone else’s code who wrote it back in 1999 and somehow the bug has been there all along undiscovered; you know where the bug is; you probably even know how to quick-fix it; but to really fix the bug knowing what you’re doing means having to understand the code. Take a graphics application and you spend more time following the code. You spend a few hours doing that, and then the patch to fix it is 6 lines long, and it’s something very very simple. You put an if somewhere to handle a condition.

Last week, the Fractal Explorer plug-in of GIMP had a bug like this. The code for handling the loglog checkbox was added back in 1999. It has never worked on the complete classic Mandelbrot set (or if it ever did work, that must have been due to a bug in some other product). Looks like nobody used it like that. Kevin Cozens was porting the plug-in to GEGL when he discovered that it crashed with the loglog setting (#372671).

GIMP's Fractal Explorer plug-in

For a Mandelbrot set, the classic method of rendering the set is to map the escape loop counter (once the modulus has escaped) directly to a colormap. This counter is an integer and the method causes banding due to non-smooth shading. The loglog implementation uses a method by Linas Vepstas to renormalize the escape loop counter by finding out how far away the integer counter has strayed outside the escape radius. It involves calculating a double log to map z^(2^i) to i, i.e., log (log (|z|^(2^i))) / log (2). The final divide by log (2) is so that the outer logarithm is done to the base 2 to reduce the 2^i to i. For reference, the end-result normalized loop counter is calculated as: mu = N - log (log (|Z(N)|)) / log (2) where N is the integer escape counter.

The problem with this method was that in the “inner lake” of the Mandelbrot set, where for example c can be 0 + 0i, the loop always exits after a full run with the loop counter at the maximum value, and |z| < 2.0. When |z| < e, the double log starts returning negative values. When |z| < 1, the double log returns inf. This is then subtracted from N and the resulting value mu is used to lookup RGB values for the point from the colormap array. This caused the plug-in to crash (when inf is used or mu exceeds the length of the colormap array).

So what we did to fix this was check to see if |z| < e at the end of the escape loop and clamp mu to N - 1 in that case. The result:

Classic smoothing (or lack of it):
Mandelbrot set without smoothing

loglog smoothing:
Mandelbrot set with loglog smoothing

Open them in two tabs to see how they differ. Of course, as we still use entries directly from a colormap (after rounding), it isn’t as smooth as we’d really like, but interpolation using the real values should be an exercise for another day. Now fixing the actual bug was a 2-line if condition. Imagine hours spent studying the algorithm used, and a 2-line fix (and perhaps this lousy blog post). The plug-in still needs to be fixed as it’s got the code for the fractal algorithms repeated for the actual filter and for the dialog’s preview, which needs to be moved to a common function, and we’d like to implement the really smooth shading as well.

Do you find all this cooking interesting? Do you want to be a GIMP developer? Come and participate by picking an open bug and hacking it into submission. Join #gimp on irc.gimp.org to talk to developers, or the gimp-developer mailing list. Or you may want to try #gegl if you think you’ve got the sk1llz.

Prisoner torture

A recent survey by the BBC shows what percentage of people in a country feel alright about torture of prisoners:

Acceptance of prisoner torture in various countries

Even in a freedom-loving country such as the United States, 36% feel alright about some level of torture (note: 36% is not an insignificant amount even if it’s not the majority). I’m even more surprised with India, where those against all torture are the minority and do not even make up half of the world-wide average. What causes people to think torture is okay, even in free societies?

Update: After reading the previous question, some readers have emailed me asking what freedom has to do with torture and I’ll try to make what I meant clearer. Respect for human rights changes closely with the level of freedom enjoyed by people. A free society guarantees fundamental rights which cannot be taken away from its citizens. These are rights including liberty (speech, gathering, etc.), equality, security (against murder, torture, rape and other crimes), and in some cases, access to welfare (basic education, health, etc.). If you look at the countries which are known for the worst track record in human rights, you will find that these are also not free societies.