Toxic Elephant

Don't bury it in your back yard!

Tips for Gimp-Perl

Posted by matijs 11/10/2004 at 12h05

After my image filtering annoyance day, I spent some more time on the problem, with more positive results.

First, I found out how to do pixel manipulations properly. It needs some incantations that are not in the man pages, but are in the source to Gimp's plugins written in C. For the basic framework of a plug-in, see Gimp-Perl's documentation and examples. For the rest, see below.

First, of course, you have to load the right modules.

use Gimp ":auto";
use Gimp::Fu;
use Gimp::Feature qw(pdl);
use PDL;

Then, the sub that actually does the work should look something like this:

sub do_something {
  my ($img, $dwb) = @_;

  my $w = $dwb->width;
  my $h = $dwb->height;
  my $gdrawable = $dwb->get;

  # make sure we can undo in one step.
  gimp_image_undo_group_start($img);

  # Read values from the source region, and write them to the
  # destination region. The destination region has its dirty and shadow
  # bits set. 
  my $src_rgn = $gdrawable->pixel_rgn(0,0,$w,$h,0,0);
  my $dst_rgn = $gdrawable->pixel_rgn(0,0,$w,$h,1,1);

  # Get pixel data as a 'piddle'
  my $rect = $src_rgn->get_rect($some_x,$some_y,$some_w,$some_h);

  # Do something with $rect's data.

  # Set pixel data
  $dst_rgn->set_rect($rect, $some_x, $some_y);

  # Magic incantations found in the C destripe plug-in.
  $gdrawable->flush();
  $dwb->update(0,0,$w,$h);
  $dwb->merge_shadow(1);
  gimp_displays_flush();

  # make sure we can undo in one step.
  gimp_image_undo_group_end($img);
  ();
}

Be sure to read the documentation for the PDL module. It explains how to manipulate the piddle with the pixel data. It helps to print part of the piddle now and then, or its dimensions (using the dims function).

Unfortunately, the method I had come up with to destripe my images didn't exactly work right. So, I went searching again. This time, I found a page describing an easy destriping method using the Gimp.

Since the method has several steps, I decided to automate it with a plug-in. I am quite happy with the result: It works on the selected layer, even if it's invisible, it handles errors gracefully, and it only works on the selection, if one is present.

Tags no comments no trackbacks

Orkut Now Comatose, And an Old New Thing

Posted by matijs 30/09/2004 at 21h19

Speaking from a pathetically low sample size, I can conclude that all ASNs go through a comatose period, where the number of users is clearly larger than the system's implementation can handle. Friendster had it, but is now fast again, and Orkut, which was fast, now has it.

The thing is, I'm not really that interested in ASNs, because after logging on, I'm not sure what I should do there, and talking to complete strangers seems just as awkward as in real life. Given that, I still would like them to be fast, for when I do get into the spirit of artificially networking on-line.

At this point, I wrote the following:

The trouble is of course the fact that all these ASNs are server-based, which makes them vulnerable to comatosity. What we need is a peer-to-peer ASN. A kind of FOAF on steroids. With a client that spiders your friends' friend lists (down to a certain level), and constructs your network on your machine. Your profile is your web page of course. Maybe some new home-page providers would spring up to provide the home-page-less with their much needed profile space.

There should be a way to send messages to other people in your network. Perhaps each member could publish a public key, and you would encrypt your message with all the public keys along the route to the person you're trying to contact, and then send it on its way. Each link in your route would only accept e-mail for this purpose from their direct friends, so a real chain linking the sender and the receiver would have to exist.

A similar public key system could help with the accessing of profiles (yes this contradicts the web page idea). Possibly at most friends of friends would get to see something not completely public.

I think this sounds great. With some more thinking, it should be possible to create something that actually works, has al the features of current ASNs that are actually nice, and avoids all current annoyances.

So, what's wrong with this idea? How can it be abused?

And then, of course, I started looking around on the FOAF site, and found out that this is, in fact, not a new idea (except maybe for the public key bits).

no comments no trackbacks

Annoyance

Posted by matijs 20/09/2004 at 20h37

I have just spent most of this day trying to get nice scans of some of my photographs. And I'm annoyed.

My father found me a working scanner in the trash. Yes, people throw away perfectly good scanners. And monitors too. I even threw away a perfectly good computer once. It was hideously old, and someone else found it in the trash. I know, because it was gone before the garbage truck came. Anyway, after a while we managed to arrange for the scanner to actually come to my house, and after fixing an endianness-problem it actually worked. Note that I consider fixing endianness-problems fun.

So, what is the problem? The scans are overlayed with a wave pattern of blue and red. It's a pattern that repeats every 16 rows, and it's perfectly predictable. It's also very hard to filter out using standard image tools.

I know almost nothing about image filtering, and I know nothing of scripting either the Gimp, or ImageMagick. So, while trying to figure out what I had to do to the image to get it right, I was also trying to figure out how to do whatever I had to do using the underdocumented scripting features of these fine programs. Let me qualify that: Gimp's Script-Fu may be well-documented, but I didn't want to combine the two things I already didn't know with a programming language I didn't know (i.e., scheme), so I stayed with the Perl version.

So, I spent a day without much progress (well, the colors look better), and I'm so annoyed, that while writing this, I smeared garlic on my keyboard.

no comments no trackbacks

Research Ideas

Posted by matijs 15/09/2004 at 22h52

I sometimes think of fun things that should be researched. These are typically topics for things like term papers. At least, I think they are. Usually I forget about them after half a day or so, and then I'm annoyed that I didn't write this wonderful idea down. These days, I'm trying to remember to write things down before I forget them.

The first item on my list of things that should be researched that I have actually remembered long enough to write down is: The history of french fries and their sauces.

Some background information on this subject: I was having dinner with some people from different western cultures recently (Dutch, German, American), and one of the Americans (my stepfather, in fact) wanted ketchup with his fries. A friendly discussion ensued, as it had previously, where we Europeans condemned the tendency of these Americans (and, by gross generalization, all Americans) to put ketchup on everything. It then turned to the subject of french fries, and who had first thought of — as the Americans put it — putting mayonnaise instead of ketchup on their fries. Hence the present research subject.

Of course, you can just google for it, and find this: The Secret History of French Fries. It still leaves the sauces, though.

On a related note, in discussions there will often be a point where someone says: We'll look it up, and somehow, the looking-up never happens, and we forget about the whole discussion. This is of course one way to end discussions.

no comments no trackbacks

Finishing Projects, Part 2

Posted by matijs 18/08/2004 at 22h50

Simon Cozens, author of the very software this blog runs on, mentions finishing projects in passing:

Maybe I need to stop coming up with interesting new project ideas, and finish some of the ones I've started.

Nah. Where's the fun in that?

How true. And how annoying that old projects stop being fun before they are truly finished. Somehow, they either linger in a mildly usable state (usable enough for me to use them, not for others), or in a half-finished and unused state, bit-rotting away. This is why I consider so few of my projects fit for publication on my website.

no comments no trackbacks

Finishing Projects

Posted by matijs 16/08/2004 at 23h06

Last month, I decided August would be the month of finishing projects. After August, I would get back to worrying about the future, but until then, I would be tying up the loose ends of the past. This is working, in a way, as I'm actually finishing a big part of my blog-project. On the other hand, lots of my old, rusting, projects won't get finished, and the blog seems entirely too recent to be spending most of my time on.

Luckily, it seems the blog software is now finally working completely.

no comments no trackbacks

A Quick Thought on Feed Readers

Posted by matijs 31/07/2004 at 15h12

After trying out Straw, I am now quite satisfied with Liferea. It does what it needs to do in a straightforward manner. However, I think there is still room for some revolutionary thought on feed reader interfaces. What I'm looking for here are new ways of managing the quickly expanding number of posts that have to be dealt with on a daily basis.

no comments no trackbacks

My very own blog

Posted by matijs 24/07/2004 at 22h01

Although I've been posting some thoughts on my home page already, it was not yet what anyone would call a blog. Mostly, I was annoyed that I had to hand-edit the HTML. Of course, there was also no possibility to post comments, there were no permalinks, etc. This had to change.

I took a look at blosxom, but quickly decided that it wouldn't satisfy my needs. In particular, it used the modification date of its input files as the date of the blog entries. This is a nice idea in itself, but I want to be able to edit — update — my posts without worrying that they'll change dates.

Luckily, I found Simon Cozen's article on Bryar, and today I finally got it working. This is not to say it was that hard, just that I have been procrastinating. Of course, not everything went swimmingly, but that's for another day.

So here it is, my very own blog.

Tags no trackbacks

More Bugfixes

Posted by matijs 31/05/2004 at 18h00

I fixed up MSGConvert some more. All outstanding bug reports were taken care of.

Tags no comments no trackbacks

News Aggregators on Laptops

Posted by matijs 28/05/2004 at 18h00

After reading about RSS and Atom (mostly on dive into mark), I decided to try out Straw, a news aggregator for GNOME. It works, but keeps spinning up my disk. Thus, it is unusable on a laptop.

no comments no trackbacks