Get email productivity tips!  
  Home    Up Contact Legal Stuff  

          You did WHAT on a Commodore 64?!

    Why, I did Digital Image Processing on a Commodore 64. Didn’t everybody??

    No, of course, most everybody did not. The C-64 was a great game machine, but it had an 8-bit 6510 microprocessor running at 2 MHz (that’s 0.002 GHz) and it lacked the number-crunching power to do anything as compute-intensive as serious Image Processing. Yet it was the only computer I owned back then, and having graduated with an MSc in electro-optics it seemed wrong that I wouldn’t use it to recreate what I’d learned. I just had to do this...

Newspaper portrait     Scan of portrait
My first successful test, a portrait from the newspaper (left),
scanned in and printed back out on the Gemini 10X (right)

    Of course, I had another problem: I had no images to process! This was 1986, before I even had a modem, and I had no digitized photos in the 170KB Commodore floppy disk format. Low-cost flatbed scanners were still in the future, as were digital cameras (in the university I had used a “flying spot scanner”, which I actually had to build as part of my thesis; this occupied a lab bench, cost thousands of dollars in parts and took most of a year to construct and debug). So my first challenge was to homebrew a cheap digitizer, which would scan a photo in a raster pattern and record the gray level at every point.
    Building a precision X-Y scan mechanism was beyond my capabilities; I had to improvise. I started with the idea that if I could get my hands on a surplus laboratory X-Y plotter, I could fit a photocell to its pen holder to do my scanning with. When this plan failed (because no plotter made its appearance) I was stumped. And then I had the “Aha!” moment: it struck me that I already had an X-Y mechanism in my trusty Gemini 10X dot matrix printer! This was already set to move the paper in the vertical direction while moving the print head horizontally, all controllable from software. All I needed to do was build a light sensitive sensor to replace the print head. The next idea was even better: leave the print head in place (after all, I still needed a printer) and make the scan head clip onto it in the right position; then feed the photo, “print” a blank page onto it, and read the sensor’s output as the head carries it across the image.
    This was a sensible plan. I proceeded to put to use the pack of assorted chipped lenses I’d bought from Edmund Scientific a while before. I designed an optical assembly comprising a cheap photo-transistor inside a focusable lens assembly made from brass tubing, and added a tiny lamp in an oblique tube to light the page under the lens. This was fixed to a binder clip that would clip onto the print head. A cable led from this assembly to a small box housing the electronics that converted the signal to a voltage range that the Commodore could read via its Game Paddle input connector. This weird gizmo, shown in the photos below, worked beautifully; at a cost of under fifty bucks, it was a true bargain.

Scanning head assembly    Scanner attachment
Click a photo to enlarge

    The next task was to craft the software that would read in images from my funny scanner, store them to floppy disk, read them back in, display them on the small TV monitor I used, and apply to them a variety of processing operations at my command. The problem was that the C-64 really was too slow, and its primitive dialect of BASIC was no match for any serious programming task. It was clear I’d need to code in assembler to get any speed out of this computer. I set out to teach myself 6510 assembly language from a book by Jim Butterfield, a leading guru in the Commodore magazines of the time.
    Equipped with the language, I bought MAE (a Macro Assembler and Editor package from Eastern House Software), and developed a program with the unimaginative name “G” (for Graphics). It was quite a task, generating 2000 lines of source code, 90% of it in assembler; and when it was ready I could honestly claim I was capable of processing images on a C-64. Of course there are disclaimers: the images were 320x200 pixels (all that the 64 was capable of!), and were in two levels of gray: black and white. Actually I had demonstrated the ability to process more gray levels, but in the interest of speed I reverted to B&W. And you’d be surprised at the amount of fun stuff you can do with that! “G” could scan images and mess around with them: invert them to negative, add them to each other with various Boolean operations, retouch them with a joystick, extract contiguous features, and perform user-defined 9-pixel weighted-sum transforms, allowing the construction of a great many custom operations and achieving effects like edge detection or noise removal.
    The photos below show some of what could be achieved. They are scanned from old printouts... alas, I had donated my C-64 to a kid in need, and these pages –- along with a stack of source printouts and an old floppy disk that may or may not be readable –- are all that I have now to show for almost a year of happy tinkering.

Raw images

Raw images: two scanned photos, a scanned drawing of a horse, and a freehand doodle (courtesy of my daughter) drawn into the program with a joystick.

Etch and Plate
"Etching and Plating" -- operators that remove and add edge pixels, and a Boolean operation resulting in edge extraction.

Noise filtering
"Noise filtering" -- removal of isolated random pixels achieved by two consecutive transforms.


Home | HOC | Fractals | Miscellany | About | Contact

Copyright © 2005 N. Zeldes. All rights reserved.