Search This Blog

Tuesday 25 September 2007

Stupid, Stupid, Stupid

Road Pricing - The UK Gummint are all for it while the tech heads point out the madness.

OK for starters I wouldn't trust Ruth Kelly to make a rational, sensible, data based decision if her life depended on it. That's a rant for another day though and probably has a lot to do with how I don't have any time at all for people who choose to listen to the little voices in their heads rather than using their brains.

She is right about the general point - road pricing or at least usage related charging has to happen in order to ration access to congested road resources. My problem with the current buzz about this is that everyone seems to be talking about technological solutions (Mandatory GPS and online comm systems for all vehicles, massive Gummint databases, location awareness systems on a grand scale, blah) that don't really exist today and would probably cost a fortune (say GBP 500-1000 per vehicle for something close to 30 million vehicles ie GBP 15-30 billion just to put the kit in the cars, possibly as much again to run given the NHS as an example of a Gummint sponsored mega IT project). Roads are expensive but GBP 60billion would still buy about 3000 miles of Grade A motorway which would solve a lot of congestion right there. And don't forget the technically trivial countermeasures outlined in the El'Reg article - implementing this is going to create an instant underground market in knobbling the tracking systems. Yeah - more crimes!

Anyway my point about all this is not that road usage pricing is a bad thing, as I said I absolutely believe it is a good thing to some extent and it is inevitable unless something else intervenes (like the sudden evaporation of all out oil reserves). The thing that makes me see red in this debate is that there is a technologically simple alternative that is known to work and that would be simple to implement: Jack up the price of fuel by an amount that produces the required effect. If this effect wears off then jack it up again, wash, rinse, repeat.... There are avoidance strategies for users (fuel smuggling in Armagh springs to mind) but the opportunities for that are limited and fuel's bulk nature makes smuggling it a hard crime to scale up economically in any meaningful way without collusion. All in all the implementation costs are close to zero as the fuel excise infrastructure is already in place and all that has to be done is to set new rates and analyze the effects.


This way you avoid a one off GBP 30bn bill that road users in the UK would have to pay and you insure yourself against being repeatedly shafted by some IT Consulting sharks by not needing them in the first place.


Getting back to Ruth Kelly - she could do with going back to being Education secretary in the hope that some learning might rub off on her. The GBP 1.30 per mile figure she quotes doesn't make a lot of sense. If it's part of a nationwide solution then it works out to a total of around GBP 390bn per annum (30 mil cars x 10k miles per annum x GBP1.3 per mile). Given that the
UK's GDP is only about a Trillion Sterling or so any nationwide road pricing scheme that charged rates like those would bankrupt the country post haste.

Monday 24 September 2007

Stuff I plan on reading

I just came across a story on Boing Boing about the new Jo Walton book, Ha'penny that reminded me of Cory's earlier rave review of the first part of that series, Farthing. I'm not a huge alternate history fan but these really do seem to be very promising.

And anything that cleverly shines a light on the utter madness of the West's current descent into fascism by proxy is very welcome indeed. Here's hoping it lives up to the hype.

Sunday 23 September 2007

What I've been reading

Richard Dawkins. "The Selfish Gene"
It's age shows a bit at the edges but it deserves its fame. One of the great books of the 20th century. I'm shocked at how topical much of the content is and that makes the areas where its age is apparent all the more jarring. 10/10 for monumentally important content but only 7/10 for style, thankfully his writing style has improved immensely since this first came out.

Vernor Vinge "Rainbows End"
It just won the Hugo for 2007 so you can safely take it that its a good SF book but I don't think it's his best work (that would be "A Deepness in the Sky" for me). That said it is still one of the best works of near future SF for quite some time. He introduces some very interesting ideas that may or may not age gracefully, but it will be very interesting to see how it manages in its own future and I can see myself returning to it to find out. 9/10 - some of his other stuff is better but even on a bad day (and this isn't a bad day) he's one of the best story tellers on the planet. This one is firmly in "un-put-downable" territory.

Terry Pratchett "Johnny and the Bomb".
I read "Only You can Save Mankind" when it came out (ie decades ago) and liked it but for some reason I never read any of the other Johnny Maxwell books. It's good juvenile fiction but pretty harmless, "Only You can Save Mankind" was a bit edgier or at least my recollection makes it so. The use of the phrase "millennium hand and shrimp" makes an intriguing appearance, or at least is interesting if you are a dyed in the wool PT fan, like the book itself. 5/10 (of academic interest only).

Peter Hamilton "The Dreaming Void"
This is the first part of Hamilton's new "The Void" trilogy that is itself a distant follow on from the Commonwealth Saga (Pandora's star and Judas Unchained). I'm not 100% taken with the plot device he uses but others might like the idea - he intertwines a medieval fantasy (of a sort) with the ongoing development of the interstellar commonwealth first seen in . The two are linked via some arm waving mysticism that he just about gets away with (for me at least) but frankly I'd be happier if he stuck with the hard SF side. 7/10

Reading:
William Gibson "Spook Country"
Niall Ferguson "Empire"
Oliver Sacks "The Man Who Mistook His Wife For A Hat"

Best Book of the year (so far):
Peter Watts "Blindsight". 10/10.

Tuesday 18 September 2007

Small Google Maps updates for Ireland

Not only have the Google Maps team have been very busy adding in loads of additional countries lately but they have fleshed out some of the area maps in Ireland too. The Google Transit team announced that all of Dublin Bus and Irish Rail's Dublin area transit stops are now updated - you can see an example here for Heuston Station.

This seems to be just a maps update and not a full implementation of Google Transit but it's a nice start. I certainly can't get Dublin Bus\Luas\DART directions to work yet but if any of you lot have any ideas then feel free to educate me in the comments.

Thursday 6 September 2007

Google Reader Updates

Google have resolved a number of major annoyances with Reader:
  • We now have a search box. Woohoo!
  • The full version now correctly reports the total number of unread items even when it is more than 100 (apparently it now tops out at 1000 items)
  • Forward and Back buttons behave as they should for a web app.
  • Google Reader Mobile has had a "Share This" link added to each article. It doesn't have a hot key as they were all already taken but it works well enough. This was fixed sometime back to be fair but it didn't get much air time.

Friday 31 August 2007

Friday Links

The Sony Rolly I'm at a loss as to what market this is supposed to appeal to but I suppose the fact that I'm blogging about it says it must be sad geeks with no sense of art or rhythm.

Casio go nuts with their
new prototype consumer super - zoom camera. 60fps 6 megapixel shooting? The highest display resolution I can find at the moment only hits 5 megapixels ( QSXGA 2560x2048 ) This is triple the pixel count of so called "Full HD" at more than twice the frame rate. I seriously hope it comes with a firewire port to plug it into the multi-terabytes of external storage it's going to need.

Rumour has it that European cellular providers are going to turn on GSM EDGE data services to facilitate the roll out of the iPhone. I won't call bullshit on it just yet because some of the cellular providers I've dealt with are easily stupid enough to consider doing this but even I'd be surprised if that happens. Anyone got any idea if the iPhone is still selling? I got my hands on a HTC Touch during the week and I've got to say that it is surprisingly tiny and lovely piece of kit but frankly I still like my phones to have a keypad.

There will be an update on the Meteor Spotting project over the weekend - this week hasn't been very amenable to giving me the time to work on it unfortunately.

Sunday 26 August 2007

More Meteor Spotting

So I left this at a point last week where I was able to get a compact representation of the changes between two images and I had a simple script that attempted to identify which sets of images were more interesting by looking for long(ish) lines on the image.

As it turns out the script I posted was pretty poor at doing this and only yielded good results if you had pretty clean data. Worse still it had some major flaws and a number of head scratching tests led me to rewrite it quite a bit. First I added code that identified the blocks of changed sectors that the code was grouping together into units and then I used that to debug the issues with the script. By yesterday I had code that could produce images like this one without making mistakes - the script posted last week has some major bugs that cause it to ignore large sections of an image. The revised script is listed below.



As you can see here the corrected script now identifies adjacent blocks correctly and colour codes them so I can quickly see what it is really doing. Small groups are ignored (where the distance covered by the group of adjacent sectors is less than 10), blue means that the mean square of the distance of the points from the longest axis of the group is less than 10, green means that it is less than 50 and red means that it is greater than 50. In general this will mean that blue marked sectors are properly interesting lines but you can see that it's not always true.

This version is a bit better at identifying the stuff I've told it to look for but that stuff isn't actually good enough. After more testing against my sample data I've found that while I can get to a point where I identify 80% of the interesting stuff with abut a 50% false positive rate on relatively clean data I about 5x that rate of false positives when I feed in very noisy data (shots of fast moving cloud cover).

A bit more research over the past few days pointed me to line finding algorithms based on Hough Transforms. This is a very cool way of switching the image mapping domain into a polar form (sort of ) that allows you to identify the "line like" features in an image. The basic idea is simple enough and one very kind soul has provided the source code for a Java demo here . I've spent most of today building the code to do this efficiently and I've finally gotten to a point where I think the transform is correct but I need to complete the mapping of the detected lines back on to the source images before I can be sure it really is working.

Tune in next week for the next exciting episode.. :)

Updated Line Finder..


$datafile=shift();
$highlightfile=shift();
$sectorfile=shift();
SetupData ($datafile);

foreach $item (@data) {
@items=split(/[^\d]/,$item);
$itemcount++;
$mapdata{$items[0]}{$items[1]}=$itemcount;
$mapitems[$itemcount]=[$items[0],$items[1],$items[2]]; # First item is 1 which means is not currently used in a line
$livemap[$itemcount]=1;

}
for ($indexitem=0;$indexitem<$itemcount;$indexitem++) {
if ($livemap[$indexitem]) {
$mstring=liner("",$indexitem);
$nscore = Analyze($mstring);
$score=$nscore if ($nscore>$score);
}
}
print "$score";
SaveSectorFile();

sub liner { # Depth First Recursive Scan for Adjacent sectors
my $lstring=shift();
my $position=shift();
$lstring .= "$position ";
$livemap[$position]=0;
for (my $traverse=0;$traverse<=7;$traverse++) {
my $new_x=$mapitems[$position][0]+$traces[$traverse][0];
my $new_y=$mapitems[$position][1]+$traces[$traverse][1];
if (exists($mapdata{$new_x}{$new_y})) {
my $new_position=$mapdata{$new_x}{$new_y};
my $bstring="";
if ($livemap[$new_position]) {
$lstring .= liner("",$new_position);
}
}
}
return($lstring);
}

sub Analyze { # Test a list of sector and score for "line-ness" Bigger scores are more line like.
my $mstring=shift();
my @points=split(/\s/,$mstring);
my ($leng,$depth,$dist,$score,$min,$max)=(0,0,0,0,$points[0],$points[0]);
$minp=int(($mapitems[$min][0])**2+($mapitems[$min][1])**2);
$maxp=int(($mapitems[$max][0])**2+($mapitems[$max][1])**2);;
foreach my $pixel (@points) {
my $tx=$mapitems[$pixel][0];
my $ty=$mapitems[$pixel][1];
my $dist2=int((($tx)**2+($ty)**2));
if ($dist2<$minp) {
$minp=$dist2;
$min=$pixel;
}
if ($dist2>$maxp) {
$maxp=$dist2;
$max=$pixel;
}
$depth++;
}
($x0,$y0)=($mapitems[$min][0],$mapitems[$min][1]);
($x1,$y1)=($mapitems[$max][0],$mapitems[$max][1]);
if ( (($x1-$x0)+($y1-$y0)) != 0 ) {
foreach my $pixel (@points) {
$x=$mapitems[$pixel][0];
$y=$mapitems[$pixel][1];
$dist +=((($y0-$y1)*$x+($x1-$x0)*$y+($x0*$y1-$x1*$y0))/sqrt( ($x1-$x0)**2+($y1-$y0)**2))**2;
}
$leng=sqrt(($x1-$x0)**2+($y1-$y0)**2);
}
if ($leng>10) {
$dist2=int($dist/$leng);
$dist=int($dist);
$leng=int($leng);
$colour=$red;
$colour=$blue if ($dist2<10);
$colour=$green if (($dist2>=10) and ($dist2<50));
highlight (\$image,$mstring,$colour,$dist2.$sectsize);
if (($dist2<10)>10)) {
if ($dist2 > 0) {
$score=$leng/$dist2;
} else {
$score=$leng*2;
}
}
print "$score $dist2 $leng $depth ($x0,$y0) ($x1,$y1)\n" if ($comments);
}
return($score);
}

sub highlight { # colour in the sectors of the provided list on the sector image
my ($im,$points,$colour,$trigger,$diff)=@_;
my $image=${$im};
my @points=split(/\s/,$points);
foreach my $point (@points) {
$image->rectangle($diff*$mapitems[$point][0],$diff*$mapitems[$point][1],
$diff*$mapitems[$point][0]+$diff, $diff*$mapitems[$point][1]+$diff,
$colour);
}
}

sub Init { # Set up dome global values
use GD;
use GD::Image;
GD::Image->trueColor(1);
$ChartImage=$sectorfile;
$image = GD::Image->newFromJpeg($ChartImage);
($limx,$limy)= $image->getBounds();
$limx=$limx/$sectsize;
$limy=$limy/$sectsize;
$image->interlaced('true');
$image->setThickness(1);
$red = $image->colorAllocate(255,0,0);
$blue = $image->colorAllocate(0,0,255);
$green = $image->colorAllocate(0,255,0);
@traces=([-1,-1],[0,-1],[1,-1],[-1,0],[1,0],[-1,1],[0,1],[1,1]);
$itemcount=0;
$score=0;
}

sub RunTest { # Create test data
$sectsize=5;
$highlightfile="Sectors.png";
$sectorfile="sectors.jpg";
$dataout=`motiontrack.exe -s 1 --sectorsize=$sectsize picture.jpg lastpicture.jpg sectors.jpg 2>dump.txt`;
@dataitems=split(/\n/,$dataout);
$data=$dataitems[1];
$comments=1;
}

sub SaveSectorFile { # Save the marked up sector file
open (IMG, ">$highlightfile");
binmode(IMG);
print IMG $image->png;
close (IMG);
}

sub SetupData { # Read in data if provided in a file otherwise run the test code.
my $datafile=shift();
if ( -e $datafile) {
open (INFILE, "$datafile") or die ("Unable to open $datafile");
$data="";
while () {
chomp;
$data .= $_
}
} else {
RunTest();
}
$data .=" ";
if ($data !~ /^(\d+\,\d+\:\d+\s+)+$/) {
print "Data Format Error\n";
exit;
}
@data=split(/\s/,$data);
Init();
}