And now for something completely different…

One of the things I spent a day doing at the end of September was add a few bells and whistles to the PAL and VHS plug-ins I wrote for the free software graphics program The GIMP.

I had found there were a few repetitive tasks I tended to do to images when I was making them look like PAL or VHS screen captures and thought I could automate these and include them in my plug-ins.

A major change to both plug-ins was that I made them scale any image fed into them to 720 x 576 (if they were not already that size). This was because the effects simply don’t look convincing on images much smaller or larger than actual television resolution.

The main change I made  to my PAL plug-in was to add an optional “interlace” effect.

The new PAL plug-in dialogue box

This is something that is designed to copy the rather stripey way PAL screen shots tend to look. There are many plug-ins that called “de-interlace” available to take the interlace effect out of images but I think this is the first one I’ve seen that actually puts the interlace in!

The interlace option creates a new layer above your image containing every other scan line from the original image. It then shifts the new layer slightly to the right and blurs it slightly with a light Gaussian Blur. Finally it merges the two layers together which creates the interlace effect.

Here’s a picture without interlacing:

Click to enlarge

And here’s the same picture with interlacing:

Click to enlarge

You’ll definitely need to enlarge the pictures to see the effect, as it’s quite subtle.

Another change I made was to add a PAL-S/PAL-D option. These are two different methods of encoding the colour in a PAL picture. PAL-D averages colours across adjacent scanlines in a field. I don’t simulate this properly yet, I simply halve the vertical resolution of the luminance which doesn’t work very well. If you’re interested, Alan Pemberton’s site has a wealth of information about PAL.

Here’s an image with PAL-S or simple PAL:

Click to enlarge

Here’s the same image, but with PAL-D selected:

Click to enlarge

As you can see from the results above, I need to do some major rework on the PAL-D feature, but I’ll save that for another day.

There were a few options I added to my VHS plug-in. The first, was to add an option to cut out the VHS picture area – this was because to save space the VHS format did record the whole of a 720 x 576 PAL image – scanlines which weren’t visible are not recorded. This is a real shame as, if VHS players did record all the image scanlines, Mike Brown would have an awful lot more vintage teletext on mb21.

You can see the picture area recorded on a VHS tape in a 720 x 576 PAL image below:

Click to enlarge

The next thing I added was a suggestion of Rory Clark. He suggested I simulate a “messy VHS head change”, which looks like a distorted area at the bottom of the picture area. You can see what a messy head change created by my VHS plug-in looks like below.

Click to enlarge

Rory also suggested that I might like to add a “glitch” that could appear horizontally across the picture at a particular point. This is what one looks like:

Click to enlarge

I added a slider so you can specify the Y position of the glitch.

The new VHS plug-in dialogue box

There are various other things to add to the plug-in such as comet tails, but I’m quite happy with how it’s coming along so far.

If you read the previous article you’ll already know that I’ve licensed my plug-ins under the GPL v3 and they can be downloaded, as usual, from here. Installing the plug-ins tends to be simplicity itself for most GNU/Linux users (simply copy it into your /home/.gimp2.6/plugins folder) but Windows users may need a bit of extra help.

I thought I’d also upload the plug-ins to the official GIMP plug-in registry so that anyone looking for a PAL or VHS plug-in there would be able to stumble across them. They’re stored here.

I was particularly pleased that a very helpful chap called “mahvin” who often frequents the registry found a bug in my PAL plug-in, and was even more pleased when he thanked me very nicely indeed for fixing it quickly. This was truly a double bonus as mahvin’s site contains his blog which is full of excellent tips on doing all manner of ingenious things in The GIMP and is well worth a read.

Obviously, each picture needs to be taken individually – these plug-ins are just a base to start from, but they have certainly given me a lot of fun, and I hope you’ll enjoy playing about with them too.

Simulated PAL

One of the many mysteries of having a home computer as a teenager was why the picture looked so much better on colour monitor than it did on a domestic television. And indeed, why the image on a domestic television looked sharper if you turned down the colour.

Later on, I discovered it was due the PAL system that the BBC Micro used to send pictures to the television. PAL ingeniously chucks away loads of colour information in order to keep the bandwidth of analogue colour television pictures down to a level that made broadcasting them practical.

After reading an excellent article on the subject by Alan Pemberton, I thought I’d have a go and see if I could simulate what PAL does to an image in The GIMP.

As a starting image, I used a CEEFAX page I’d made in Teditor (by Jim Notman, The Micro User, Volume 2 Issue 6) on the BBC Micro emulator BeebEm. Obviously teletext looked nothing like as good as this on a domestic television.

My starting image – click to enlarge. It never looked this good on a telly!

To begin with I added a Gaussian Blur to the image. I broke the link between the horizontal and vertical blur radii so that I blurred more horizonally (2.2) than vertically (1.2). It’s worth playing with this.

This button breaks the link between the radii

The next thing I needed to work out was how to split the image up into three different images – one containing red, one containing blue and one containing green. I discovered the Levels dialog box in The GIMP would do this for me.

To make the Red channel I created a duplicate of my original image with Ctrl+D. Then I brought up the Levels dialog box and then:

  1. selected blue channel from the Channel combo box
  2. dragged black pointer below the input levels graph to far right
  3. selected green channel from the Channel combo box
  4. dragged black pointer below the input levels graph to far right

The Red channel

To make the Blue channel I created a duplicate of my original image with Ctrl+D. I brought up the Levels dialog box and:

  1. selected red channel from the Channel combo box
  2. dragged black pointer below the input levels graph to far right
  3. selected green channel from the Channel combo box
  4. dragged black pointer below the input levels graph to far right
The Blue Channel. Sounds a bit rude…

Finally, I made the green channel from my original image. To do this I:

  1. selected green channel from the Channel combo box
  2. dragged black pointer below the input levels graph to far right
  3. selected blue channel from the Channel combo box
  4. dragged black pointer below the input levels graph to far right

That meant I had three images – one which was the red channel, one which was the blue channel and one which was the green channel.

The green channel was finished – I didn’t need to touch this as the PAL system relies on a high resolution green image and adds a low resolution red and blue image to this.

The finished Green channel. It will not be scaled like Red and Blue.

However, to both the red and blue channels I needed to lower the horizontal resolution quite drastically. Therefore I scaled both images to be 197 x 576. Then scaled them both back to 788 x 576 – their original size – again.

The Red channel after being scaled

Next I copied both the red and blue images into the green image as new layers. I used the Addition blend mode in the Layers, Channels, Paths dialog box to blend the images together.

Here is the low resolution red image added to the high resolution green image.

Red and Green images on separate layers blended using “Addition”

Here are the low resolution red and blue images added to the high resolution green image.

The end result – click to enlarge.

Well, it’s not perfect, but it was nearly what I was after and I was over the moon.

With a bit of playing around with the way you scale the channels it’s possible to get a fairly realistic PAL effect. The image below has various filters added to it, and I think it looks like an almost passable knock off of an off-screen photo.

Click to enlarge. Needs a bit more work, I think.

What I want to do next is to turn this into a filter in Python to automate the process and allow it to be fined tuned.


The Acorn World show is taking place on 12-13 September 2009 and I’ve done several of bits and pieces for it. One run of the mill job was that I recreated the Acorn World logo as an .svg as organiser Dave Moore only had it as a small bitmap.

My svg vector Acorn World logo

However, after that I was asked to do something a bit more unusual. Dave wanted to have a real BBC Micro show a selection of pages of information to people arriving at the show, and asked me if I could do something in teletext Mode 7.

Creating teletext graphics is quite fiddly as there are numerous limitations you have to be aware of – if I hadn’t done a lot of teletext work back in the 80s on my Beeb (mainly lame mickey takes of Ceefax and Oracle) I would have found this job tricky.

The teletext mode consists of 25 lines of 40 characters. As far as graphics work is concerned each character space is made up of a grid of 2 x 3 pixels. That gives you an effective resolution of 80 x 75 pixels. You are limited to 8 primary and secondary colours. However, each character square can only hold two colours (foreground and background) and if you want to change one of the colours (either foreground or background) you need to have a blank square to hold the colour change.

The first thing I did was take export my Acorn World logo from Inkscape as a bitmap. I imported it in The GIMP and convert it to an indexed palette consisting of black, red, green, yellow, blue, magenta, cyan and white. I already had this palette handy as it’s the standard one I use when creating BBC/Electron loading screens.

Next I reduced the size of the image to 80 pixels in width. After that I then created a grid using guides on the image spaces two pixels apart horizontally and three pixels apart vertically. This corresponded to character squares on the image, which is very important. You need to see easily where the character boundaries are in order to work out where you have blank squares in which to change colour. It also helps you create the artwork on a BBC Micro.

The first character space had to be black, as that would be where I would change the graphics colour to white. I also had to make sure that the green Acorn did not overlap any character square used by the black writing – this would have been impossible to render in a teletext mode.

All ready to enter on a BBC Micro Emulator?

One special difficulty of this screen is that you cannot do black graphics on a white background in teletext mode on a BBC Micro (although teletext enabled TV sets can do this). You can only do white graphics on a black background. This may sound odd, but only being able to do the latter makes it much more difficult to change colours.

For instance, I had no white background when I came to do the green on white acorn, as the background for the “Acorn” text was black. This meant I needed two colour changes (one for the foreground and one for the background) and this takes two character squares. The Acorn in the picture shown above needed to be shifted right by a character square to allow room for this.

Next I needed to get my design into a BBC Micro. I’m not lucky enough to have a real BBC Micro here in Hungary, so I use the excellent free software BBC Micro Emulator BeebEm. Sadly, on Ubuntu Linux, I have to run the Windows version under Wine as the GNU/Linux port has been rather neglected.

Back in the 1980s I used to use a teletext editor called “Teditor” by Jim Notman that I typed in from a program listing in The Micro User (Volume 2, Issue 6). However, these days I use a program imaginatively called “Teletext Screen Editor” that I got from a link in a thread on The Stairway To Hell forum. It’s a particularly good editor as it has something called “Graphics Mode”. This means that the letters QW, AS and YX act as toggles for individual teletext pixels in a character square. This is a huge help.

When using a BBC Micro utility you really miss modern niceties like auto-saves and multiple undos! Therefore, in case of accidents I use the BeebEm “Quick Save” save state function to save my work regularly.

The finished result in the editor

All I have to do in the teletext editor is “type” the screen in using my GIMP image as a guide, and send off a BBC Micro disc image to Dave to load onto a real BBC Micro.