Tuesday, July 22, 2008

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.

As I'm writing this I'm sitting outside trying to survive the blistering heat of the Norwegian summer. (20°C) Global warming indeed! The sun is scorching my poor untanned flesh... I'll probably be lobster red by the time I'm finished typing.

During last week's conference call, several interesting points came up:
  • I should create an AnnotatedImageHandler, which will handle storage and retrieval of both images and their annotations.
  • Look into more standard XML formats for storing image metadata and annotations, if they exist.
  • Complete the module to the point where other developers can easily try it out on their own, and post that to the openmrs module repository. Sooner rather than later.
  • Collect input from other developers and prioritize changes/features based on that.

In addition to this, the annotation system needs some more work before it can be considered complete. I also need to update the wiki page again, but I don't feel like doing that right now. Haha, what a rascal I am!

Right now I'm focusing on the new AnnotatedImageHandler. I'll store annotations the same way as before for now. If I decide to change this later, I'll only need to update the handler, the rest of the code will be unaffected.

Panzer madness!

In my third installment of war stories you'd want to tell your mates down at he pub, I'll discuss some interesting German tank designs.

During the second world war, the Germans made a shift in tank design from light, mobile vehicles to heavier models with greater firepower. They had several very successful designs, culminating in the Tiger and especially the Panther. Several countries modeled their post-war tank designs on the Panther.

After the German invasion of Russia got underway, German intelligence uncovered roumors of a new Russian super-heavy tank being built. Predictably, Adolf Hitler ordered the development of a German super-heavy in order to counter the Russian one.

The first proposal came in 1942 from industry giant Krupp: The Panzerkampfwagen VII Löwe (Lion) came in two versions, the Leichter Löwe (Light Lion) at 76 tonnes, and the Schwerer Löwe (Heavy Lion) at 90 tonnes. Hitler immediately scrapped the light version and ordered the heavy model to be super-sized with a bigger gun, thicker armor and higher speed. For comparison, the Panther weighed 45 tonnes and the M1 Abrams, the current main battle tank of the US army, weighs 65 tonnes. (Tonne = metric ton, 1000 kg)

Before Krupp could figure out how to achieve both greater speed and heavier armor at the same time, Ferdinand Porsche (yes, the founder of the automobile company) countered with the Panzerkampfwagen VIII Mammut (Mammoth). This monstrous design weighed in at 188 tonnes, was 10 meters long and 3.5 meters wide, had a crew of five and had a top speed of 20 km/h. It was to be armed with a new 150 mm anti-tank gun, which was also under development. As you may imagine, Hitler ordered an initial delivery of 150 tanks, and shut down development of the Löwe. Masters of understatement, the Germans renamed the Mammut to Maus (Mouse) in 1943.

The Maus would have been highly resistant to enemy fire, an would have been able to deal out a huge amount of damage. The project was plagued with technical difficulties, though. For one, no enginge could be found that was up to the task, and the prototypes couldn't go faster than 13 km/h under ideal conditions. Second, the tank was too heavy to cross most bridges, so it had to be redesigned to ford or run submerged using a snorkel across rivers. Thirdly, the new gun was delayed and a smaller one had to be used instead.

Only two prototypes were ever built. By the time they were almost ready for use, the Soviets overran Kummersdorf where they were located at the time. The first prototype had been fitted with a dummy turret, and was captured by the Soviets. The second one had a working turret and was shipped off to Berlin to be used in defense of the city. It broke down before it got there and was blown up by its crew to prevent it from falling into enemy hands. As the Soviets found the second prototype they discovered the turret still almost intact, and combined the #2 turrent with the #1 hull. The combination vehicle was shipped back to Russia for testing, and can now be found at the Kubinka Tank Museum.

Make eet bigger!

The Maus wasn't the only super-heavy design, though. Krupp had another ace up his sleeve, the Landkreuzer P. 1000 Ratte. (Rat) This tank was so ginourmous that it wasn't even designated a tank. A new designation had to be invented: Landkreuzer literally means Land cruiser.

The design called for a crew of 20, a length of 35 meters and a width if 14 meters. It had a gun for every purpose. Living up to the land cruiser designation, it was armed with a modified cruiser turret, sporting two 280 mm naval artillery guns. These had a range of 5 km in direct-fire mode, (aimed directly) or up to 40 km when tilted upwards for a curved trajectory. These guns were too big to be used against something as frivolous as enemy tanks, so a third, smaller gun (128 mm) was to be used for that purpose. In any way, this was not a critical part of the design, as no tank could possibly penetrate the armor of the Ratte. In addition to the three guns, the land cruiser would have sported eight anti-air flak guns on top, and probably a few machine guns to clean up the rest... like people, or elephants.

The power plant might have consisted of up to eight Daimler-Benz diesel submarine engines. The design specified a weight of an un-freaking-believable 1000 tonnes, though this was probably too optimistic. Post-war analysis of all the specifications led to an estimate of closer to 2000 tonnes.

No bridge in the whole of Europe existed that could carry the Ratte, so the design counted on the height of the vehicle allowing it to ford most rivers. Had it been successful, the Ratte would have been an awesome sight to behold. The Maus destroyed all roads it drove across. The Ratte would have plowed a new field. Buildings would have been torn down just by the vibrations in the ground. Being able to stop an enemy offensive single-handedly is quite impressive too...

This kind of super weapon design was just the thing Hitler loved, and he ordered Krupp to begin immediately. It was not to be, though. The design was fundamentally flawed in that it could not possible have been worth the enormous resources required. The technical difficulties were significant, of course, and the Ratte had a major weakness: The huge size, slow speed and inability to disguise itself would have made the land cruiser a prime target for enemy dive bombers, which would have quickly knocked out the Ratte's engines through the weaker topside armor.

Does it end there?

You know it doesn't! If you have any interest in military history at all, you'll probably have seen about a dozen documentaries about Schwerer Gustav, the largest rifled weapon ever made. Schwerer Gustav was an 800 mm artillery cannon mounted on a railway car. It was designed to destroy large, heavily fortified targets, and was in actual use during the German invasion of Russia.

Back in 1942 when the Ratte project was initially approved, Hitler gave orders to make his beloved railway gun self-propelled. I pity the designers at Krupp.

Enter the Landkreuzer P. 1500 Monster. Too big for the irony of a name like "mouse" or "rat" to work. The Monster was simply a version of the Ratte scaled up by 50%, and using the Schwerer Gustav for a main gun. The designed called for a weight of 1500 tonnes, but like the Ratte, this was too optimistic. A more recent estimate has put it at 2500 tonnes.

Obviously the Monster had the same design problems as the Ratte. The combined resources required for these two projects might have devastated the German war industry, if not for the dangerously clever Albert Speer.

Albert Speer was the minister of armaments, and he had a special knack for spotting Hitler's most wasteful and demented projects. He canceled both land cruiser projects in 1943.

Oh, and the rumours of Soviet supertanks were of course false. The Soviets had kick-started their tank manufacturing, that was true... but when they finally were ready they completely overran the Germans with tens of thousands of small, light and fast T-34 tanks.

Monday, July 14, 2008

You! What planet is this?

Yesterday I completed the basic functionality of the annotation system for my image viewer, using the Google Maps' marker feature. Each marker is shown as a red icon overlaid on the image. If the marker is clicked, an info window (looks like a comic book speech balloon) will open, displaying the annotation text.


So far it is possible to create new markers and view the existing ones, but they can not yet be moved, edited or deleted. This will obviously have to be implemented. Also, I would like to change the default marker icons used by the Google Maps API. Finally, the shadows that the API uses behind the markers and info windows seem unnecessary and potentially confusing, so I may remove them.

The image viewer saves and loads annotations using AJAX, so reloading the page is not necessary. The current implementation stores annotations as an XML file in the complex obs directory, but this can be changed fairly easily.


HMS Habakkuk

Though reading about my summer of code project must be quite captivating, let's move on to something even more interesting.

Project Habakkuk was a British plan to construct the world's largest aircraft carrier during WWII. This project was the brainchild of English journalist/spy/inventor/mad scientist Geoffrey Pyke, and was based on his most famous invention: Pykrete.

Pykrete is a composite material made by mixing sawdust or wood pulp with water, and then freezing it. The optimal mix is supposedly 14% sawdust and 86% ice (by weight). The properties of this material are quite impressive: It is easy and cheap to make, incredibly tough (comparable to concrete) and has a very slow melting rate.

Project Habakkuk, if successful, would have involved creating a huge, unsinkable floating island out of pykrete, probably in the Canadian winter. The top side would have been leveled to make room for one or more airstrips, and the center hollowed out for storage of 150 twin-engined bombers or fighters. Several anti-air installations would have been added, and the ship may have been reinforced with steel.

The final design called for a displacement of 2.2 million tons (the American Nimitz-class supercarriers have a displacement of 80,000-100,000 tons) and a length of more than 600 meters (twice that of the Nimitz-class, and enough for an airstrip suitable for the heavy bombers of the time). Steam turbogenerators would have supplied 26 electric motors mounted on external nacelles, similar to the way propellers are mounted on an airship.

A possible design for the HMS Habakkuk, shown next to an Iowa-class battleship and a Nimitz-class supercarrier.

HMS Habakkuk would probably have been impervious to submarine attack, and highly resistant to enemy bombing raids. Refrigeration plants would probably have been added to prevent melting, although the slow melting rate of pykrete may have enabled the ship to last for a year even without these.

Geoffrey Pyke presented his idea to British Admiral Lord Mountbatten, a favorite of Winston Churchill, and the uncle of Prince Philip. Mountbatten in turn presented the project to Churchill in 1942. Several tests were made to optimize the properties of pykrete, and a scale model was constructed in Canada.

At the Quebec Conference of 1943, Lord Mountbatten made a demonstration for a group of admirals and generals along with Winston Churchill and Franklin D. Roosevelt. Mountbatten brought a block of normal ice and a block of pykrete, to demonstrate the strength of the new material. He placed the blocks on the floor, drew his service pistol and fired at the ice block, which shattered. He then fired at the pykrete. The bullet ricocheted off the block, grazed the leg of US Admiral Ernest King, and ended up in the wall. The Admiral was highly impressed by Mountbatten's unorthodox demonstration.

Project Habakkuk began to lose priority later that year, and it quickly became apparent that the technical difficulties and the enormous resources required were too high.

It took three hot summers to completely melt the Canadan prototype.

Thursday, July 3, 2008

Gentlemen, you can't fight in here! This is the War Room!

The image tile servlet is more or less complete, and I can now create tiles from images of any size (or so I believe) without using lots of memory. As I mentioned in my previous post, the largest image I'm currently testing with is 8192*9976*8 bits. I'll dig up some even larger ones soon and do some further testing.

The servlet now works as follows: The Google Maps image viewer figures out which tiles it needs based on the state of the view window, and makes HTTP GET-requests, like so: imageTileServlet?obsId=6&x=0&y=2&z=5

For each request, the image tile servlet should return a 256x256 pixel JPEG image. It looks up the obs with the given id, and opens the file given by its "complex" value. The servlet then reads metadata from the file (dimensions and bit depth). Based on this and the GET parameters, the servlet can calculate the relevant part of the image and set the correct image read parameters, like so:

ImageReadParam param = reader.getDefaultReadParam();
param.setSourceRegion(new Rectangle(xpos, ypos, tileSize, tileSize);
param.setSourceSubsampling(subsampleLevel, subsampleLevel, 0, 0);

SourceRegion is the part of the image we are interested in decoding. SourceSubsampling allows the reader to skip pixels while reading, if set to 2 the reader will read every other row and column.

The servlet will then resize the image using a Graphics2D object, encode to JPEG and write the resulting stream to the HttpServletResponse object. The user's web browser will in most cases cache the images, so each tile shouldn't need to be requested more than once.

So far the source image must be a JPEG file, but adding PNG, GIF and BMP is a simple matter, as Java's Image I/O API has built-in support for these formats. I also plan to add DICOM image decoding at a later time.

Right now the tile servlet is a little sluggish. I have my test deployment of OpenMRS running on a Pentium III laptop with Ubuntu server. Loading an image tile from my largest JPEG takes several hundred milliseconds. Smaller images are read significantly faster.

I have created a portlet that contains the Google Maps-based image viewer. I'm currently ironing out a couple of JavaScript and CSS issues, which I expect to resolve soon. As the svn server is supposedly up and running, I'll probably make my first svn commit when this is completed, though I may do a little cleaning up and refactoring first.

I also believe it is time to update the wiki page for my project, I'll probably get that done within a couple of days. Next up is support for annotations.

 

Now, with all that out of the way, let's talk about something really interesting: Amusing facts from WWII.

During the war, the British developed a new class of bomb to use against bunkers and submarine pens, the so-called earthquake bomb. The design was built in two sizes: The 5400 kg 'Tallboy' and the 10000 kg 'Grand Slam'. The Grand Slam was the world's largest bomb at the time. These weapons were dropped from specially modified Lancaster bombers and reached supersonic speeds before hitting the ground. The bomb casings allowed the weapons to penetrate several meters of soil and concrete before detonating their massive load of torpex high explosive.

At RAF Scampton, a Royal Air Force base north of the English town of Lincoln, a Lancaster bomber and a Grand Slam bomb were set up as "gate guards" after the war. In 1958, the road going past was going to be extended and the gate guards had to be moved. They rolled out a crane and tried to lift the bomb, which for some reason wouldn't budge.

The RAF crew initially suspected that the bomb casing was filled with concrete, or had filled up with water over the years, but then someone got a horrible suspicion. "No... It couldn't be... could it?" This area had been open to the public, and a lot of people had climbed up on the bomb and taken pictures sitting astride.

So, they called up a technician who carefully scraped off the paint and opened a service hatch. Right enough, the Grand Slam bomb was still filled with explosives from 1944!

A bigger crane was called in and the bomb was carefully moved under police escort to the coastal experimental range at Shoeburyness. There it was rigged for demolition, and the resulting explosion proved without a doubt to anyone within a 16 km radius that the bomb was still very much alive.

Carefully does it!

The subsequent investigations failed to determine how a live earthquake bomb could have been set up as a gate guard. They crunched some numbers, and estimated the damage the bomb could have done if detonated at its location outside the RAF base. Besides taking out the base itself, the bomb might have flattened most of the northern part of Lincoln, including the cathedral dating back to 1250.