The process of converting scanned film images to individual frames and avi movie files is not too complicated. The math and logic behind the methods are quite simple. Basically, you have to identify the sprockets, pick off the images, and compile them into a movie file. Identifying the sprockets sounds easy, but actually makes up about 90% of processing time and program code.
My program is built around a graphical user interface (GUI) to allow the user to be able to use the same code for many different operations including scanning and processing film, reprocessing a set of previously scanned film images, continuing a project that was interrupted before completion, or compiling a movie file from previously captured frames of a film.
The user may choose regular 8, super 8, frame rate, motor delay (time to wait between sending signals to the motor), automatic or manual calibration of sprocket size and position, and whether to create debugging images.
The main program simply keeps track of the number of scanned images and the number of frames that have been picked off and orchestrates the execution of the routines that advance film, initiate a scan, process the scan, and create the movie file.
In general, the program executes the following suedo-code:
Initialize parameters (depending on user choices)
Check to see if Scanning software is ready
- Not ready? Tell user and stop execution
Ask User for working directory
Create output directory
Number of scans = 0
Number of frames = 0
Main program loop
- Add 1 to total number of scans
- Check to see if there are 999 scanned images
- - Have 999 scanned images? Change file name & reset counter on Epsonscan software
- Predict filename of next scanned image
- Start Scan
- Scanning Loop
- - Check to see if expected file exists
- - - File Exists? Exit Loop
- End Scanning Loop
- Create grayscale Image
- Find edges
- Find Sprockets
- Pick off frames
- - Add frames picked off to total number of frames
- Advance Film
End Main Program Loop
Advance end of film through machine
Create movie file(s)
The next sections cover the algorithms for finding edges and sprockets in more detail.
A lot of time can be saved if the scanned images of the film are straight, consistent, and have little extra space above and below the film. In general, the top and bottom edge of the scanned film image should come as close to the film edge as possible. The edges of the film may even be cut off slightly, but cut too much off and the program will be unable to accurately find the sprockets or the frames.
In finding the sprockets, the full image is not needed. Only the top 1/3 - 1/2 of the image is required because once the position of the sprockets is known from the smaller, working image, the frames can be taken directly from the original image. Performing the sprocket finding algorithms on only the top third of the image reduces processing time by 75%!
Go on to Bitmap Tutorial