Harri Kaimio

     
 

Film scanner photos


I finally managed to add some photos of my film scanner setup to Freecine web site.


 

 
 
 
 

Freecine Is Now... Free


I finally managed to get my home telecine software into a state that might make sense to others. So I am placing Freecine under GPLv3.

Freecine contains both the PC software for controlling the scanning process and postprocessing scans as well as the software running inside NXT. It is written in Java, but as it uses some native services it most probably does not fully work in other environments than Linux. That said, porting it to WIndows or Mac should not be too difficult.

Currently Freecine is still very tightly dependent on my environment, so it will certainly need some tweaking to get it work. I intend to do a proper release shortly (next weekend?), so until then consider this as a sneak preview ;-) But for those who are interested, the source code is available from Mercurial repository at http://www.freecine.org/hg/freecine. There is also Wiki (which will eventually contain instructions for building the system and running the software) and mailing list. Please join it if you are interested in using this.

The software has a simple UI for scanning the film and doing some pretty basic color corrections. I have developed much more sophisticated color correction features for Photovault, my photo archiving application and I plan to copy those to Freecine as well.


My frame/perforation detection algorithm starts to be reasonable robust, but sometimes it gets fooled by dust inside the perforations or image details that look too much like perforation. Therefore it is also possible to manually adjust the location of perforations.

 

For now it is possible to save the images as PNG files which can be then converted into a movie by tools like ffmpeg. I am looking at integrating gstreamer into Freecine, so that it would be possible to export directly in movie file format.

Contributions Welcome

I believe that Freecine provides a good starting point for others who want to build a home telecine but it definitely needs further development. I will continue to enhance it for my own purposes but I really hope that you will also contribute your improvements if you find it useful.

About the Name

I choose the name "Freecine" because it rhymes nicely with "telecine" and I would like this to become a free project (in the sense of freedom) After selecting the name I found out that a while back the Cinerella community version considered independently exactly the same name. However, as they have now decided to use the name "Lumiera" I hope that I don't stump on their toes with my choice of name.

 
 
 
 

Going Java


I finally managed to simplify my film scanning software setup to usable level. If you have read my previous entries, you may recall that I have used commercial scanning software (VueScan) for scanning, Lego "G language" for the film mover control inside NXT, custom Java SW for splitting frames from scans and a bunch of Python scripts to tie all this together (using Dogtail to control Vuescan...) Although this kind-of-worked, the setup was very error-prone and difficult to set-up. So I decided to get rid of all other components and integrate all functionality into a single application.

My first step was to change NXT firmware into leJOS, an open source Java virtual machine that runs in NXT. This was my first experience with leJOS and it was very positive one. Of course, Lego's graphical programming environment is very good for its purpose of teaching robotics to children, but  real programming language has still clear benefits - especially when implementing communication between PC and NXT. leJOS was really simple to use - I haven't have so much fun writing software for long time. Highly recommended.

While redesigning the NXT software I also changed communication channel from Bluetooth to USB to ease system setup.

Scanning from Java

Next I started to look for alternatives for VueScan. There are several solutions available for controlling scanner from Java application. Most of them use the SANE network protocol to access scanner in Linux, and  I did not want that as my scans are big (one strip is roughly 240 MB). In the end I decided to access SANE native libraries directly via JNA.

I receive the raw linear 16 bit scanner data and store it to a tiled TIFF file (another benefit from implementing scanning myself was that I could reduce memory usage by selecting optimized tiling scheme). I then detect the perforations and either save individual frames immediately or store the perforation information to XML file and do splitting later (I prefer the latter method as I can then adjust colors and correct any errors manually)

The only thing I miss from Vuescan is infrared cleaning that is not supported by Sane's Epson back end. Thanks to some help from Internet community I now know how to enable infrared in the scanner, but this must still be implemented in SANE back end. Also, actually using the infrared channel would require proper and fast dust removal algorithm. For now I am relying in a more traditional dust removal method: antistatic cloth and pressurized air...

 
 
 
 

Film Holder


Some readers have asked for better pictures of the film holder I am using, so here we go. I hope this attempt to explain the structure is more successful than the photo in my last post.

 

The body of the film holder is made from two stainless steel rulers. I carved a ~0.3 mm deep and 0.5 mm wide "stair" to the edge of the rulers (using a Dremel miniature drill mounted into a router table). The film lays on top of the stair. Then I glued four plastic strips on top of the rulers (the blue ones in the picture): two to keep the rulers tugether at the correct distance and two to hold the film flat from its edges.

 Here is a side picture that shows the structure in more detail:


The design has worked quite well - the film still bends a little but not too much (the rotation needed for frames in the same scanned strip is typically within 1 degree). One design flaw in this setup is that it is not possible to remove the film in the middle of scanning a rollm but in practice this hasn't been too big problem.

 
 
 
 

Progress with Film Scanning


I have been busy with work and haven't had as much time for the film scanning project as I would have liked but still, it is alive. The system starts to be stable enough for real scanning - I have scanned several long reels without any major problems with software or equipment failures. Still, tuning the systems has proved to be quite difficult - as the S8 frame is  only 6x4 mm (roughly) even small errors are visible as huge quality problems.

Better  Film Holder

My first film holder was made from two stainless steel rulers that pressed the film against scanner glass from both sides. In practice, the film could bend a little and this showed as the image "wobbling" that repeated every 2 seconds or so. Pretty annoying. I considered several ways to correct this, both using software correction and better hardware. Some others have succeeded in the former by using Hough transform to detect frame edges and then warping the image to correct shape. I choose the hardware route.

My new film holder is done from the same rulers I used in the first one, but now they are between scanner glass and film. I used my Dremel tool to make  a small stair (about 0.5 mm wide and deep) to one side of both of those. Then I glued  a plastic board on top of them, so that the stair holds the film at a suitable distance from scanner and the plastic keeps it flat.

 

(Yes, I know, not the best picture I have taken but it shows the basic structure)

Here is a detail about the edge that holds the film:

  

The new holder has been quite succesfull. The film stays now flat and the distance from scanner lens is just right so I get significantly sharper scans as well.

Frame Detection

This has been the another major challenge. At first, I thought it should be easy - after all, the perforations are the brightest spots in the scanned image. However, in practice the films have many weird anomalities and with even 0.1 % error rate we get several bumps every minute.

Here are some examples of problem cases (Both are raw CCD data from scanner, so there are no more details available)

 

As you can see, one perforation is not visible at all because the emulsion has been damaged when cutting the film. And after that, there is very bright sky and dark silhoutette of a building that easily fool edge detection algorithms.  


The example above shows another case where the perforation edge is not visible due to bright sky.

So the challenge is how to detect frames with very high accuracy (error of couple of pixels is already very visible) and avoid misinterpreting special cases (like damaged perforation or features looking like perforation edge in the image)

I have spent quite much time improving the perforation detection and I start to be close to correct one. There are still some special cases that cause problems - I'll write a separate post when I get those solved.

Dust Removal

Dust and scratches are currently my biggest image quality problem. Getting the film as clean as possible before scanning is of course the easiest and best solution (the film moves through soft cleaning cloth in my current setup) but it is not perfect.

Currently I use the infrared cleaning featue of VueScan but I am not completely happy with it. Most of my films are shot on Kodachrome stock, and its dyes absorb infrared light more than other film stocks. Vuescan does usually decent job in detecting dust but in the case of Kodachrome it also classifies sharp edges of dark objects on light background as dust. Another thing is of course that I would like to get rid of Vuescan in my workflow (it is GUI software not intended for this use, not well scriptable and and a problem for releasing the project) I have considered implementing infrared channel support to Sane Epson back end but the documentation needed for this seems not to be accessible without NDA...

So - the project is alive and well. The main things in "productizing" the software are now those I mentioned above - perforation detection and Vuescan dependency - I am considering to release the SW as open source project after solving those.

 
 
 
 

Merry, Merry Christmas!!!


 
 
 
 

About Me


I am 36 years old software professional living in Vantaa, Southern Finland. I currently work for Nokia as software architect, mostly with low level system software for our phones and other mobile terminals. You know, that supposedly invisible code that is nevertheless crucial in bringing devices into life.

This blog is about my hobby projects. I have been photographing passionately for almost three decades, and I like to mix photography and technology in interesting ways.

 
 
 
 

Fun with Mindstorms & Old 8mm Films


 


 

As a teenager in the 80s I was actively shooting films with my Super8 camera. Most of the stuff was just documentary about my family and friends but I had also more ambitious projects. As so many other in that age I even dreamed of a career as professional film maker before choosing the easy way of playing for my strengths in physics and IT.

That was 20 years ago and I don't any more have a working film projector. I did transfer the films to VHS tape a long time ago but the quality was quite poor (and no, I don't have a VHS recorder either). So I have been looking for a way to could digitize the films with a better quality and into format that would stand time.

I have used an Epson 4990 scanner for digitizing my photo archive. It is a very high quality flatbed scanner that can scan 4 strips of 35 mm at once. The obvious question was that could I use it to scan my Super8 films as well?

The basic idea was simple: the scanner lid is wide enough to fit about 2 seconds of 8mm film at a time. If I could scan these, somehow extract the individual frames from the scanned image and move the next 2 sec of the film to the scanner... Should be easy, but this must be automated (I don't want to sit next to my scanner and transfer the film 30 times to get one minute of material...)



My sons love playing with LEGOs and the the Mindstorms robotic kit seemed just the perfect solution for building a prototype of my telecine concept. So we made a deal: they build the film transport system from LEGOs and I take care of the other parts, mainly the control and image processing software needed.

The Transport System


The LEGO part has two main functions: it must pull the film from scanner so that the next unscanned piece of film gets ready, and it must rotate the film reel into which the scanned film goes. We used 2 Mindstorms servo motors, one for each task.

The film is pressed between 2 soft Lego wheels that are rotated by one of the motors. We placed some guides on both sides to the wheels to ensure that the film moves straight (luckily, some Lego parts have exactly 8mm holes in them!)

The film reel is rotated with the other servo. We reused the film guides to detect when the film is tightened and the reel must be stopped.

The most difficult part was to figure out how to keep the film flat in the scanner. Because the frames are only 4x6 mm, even a small bend or twist causes visible warping in the scanned image.  We tried many alternatives (ranging from innovative Lego creations to correcting the warp in software), but finally we built a film guide from 2 stainless steel rulers that press the film from both sides against the scanner glass. The system is not perfect but good enough: There is still some jitter caused by bending film but that is tolerable.

The Software


So, the boys did their part and it was time for me to keep my promise! The Mindstorms central unit has a Bluetooth chip and Lego folks have done excellent job in documenting their system so controlling it from PC was easy. Controlling the scanning was another matter.

I ended up using VueScan (by Ed Hamrick) as a scanning software. Despite its, well, not so intuitive UI it can produce better image quality than any other scanning software I have tried. And as far as I know it is the only scanning software in Linux that supports infra-red cleaning. The problem: it is a GUI application and does not have any scripting support. So it required a relatively large amount of hacking to integrate it to other system (hint to Ed: I would love a command line version of VueScan!!!)

I scan 32 frames of film at once and save it as a single image. After that I use custom software to detect the perforations in the scanned image (they are the brightest areas in the scan, so this is relatively easy) and extract individual frames to separate files. Then I use the video encoder of my choice to create suitable video file.

The Results

The resulting video is of surprising high quality, considering that I haven't spent a lot of time for tuning the image processing part:



Things to Do

Of course, the current system is a prototype. The things I would like to do include:

Image enhancement. I haven't spent a lot of time in fine-tuning the image quality. The thing that disturbs me most is chromatic aberration. The small frame size exaggerates it and apparently the lenses in cheap S8 cameras were not really top quality. This shows up as colored edges around people and objects.

Correcting chromatic aberration is quite easy but integrating it to my processing pipeline needs still some work. Also, sometimes there is effect that looks like CA even in the centre of the image. I wonder if the viewfinder prism could cause this (In S8 cameras, part of the light coming through lens was reflected to viewfinder by a prism. There was no mirror mechanism as in SLRs and more expensive 16 and 35 mm film cameras)

Speed. Now it takes about 2 minutes to scan 2 seconds of film (with 4800 dpi resolution and infrared cleaning). This is quite OK for me as I can leave the system running overnight but of course it could be faster.

Integration. Now the system has been glued together from LEGOs, other off-the-shelf hardware, Python scripts, GUI testing toolkit (for controlling VueScan), commercial software, custom Java code and (literally) duck tape. It works but it isn't pretty. It would be much nicer to use (especially for others) if some of the components would be removed and the whole thing packaged into a single program.

Sound. Well, for now I have enough mute films to play with but digitizing sound needs some further thinking...

All in all, this was a fun project, full of interesting challenges for kids and dad alike. And even if you can learn a lot by just just playing with LEGOs is  it is still better to see how that differs from engineering a working system.



 
 
 
 
 

« joulukuu 2014
matiketopelasu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    
       
Today
About Me
Software professional living in Finland. This blog is about my hobby projects, usually related to photography and technology.

See more

Valid XHTML or CSS?

[This is a Roller site]
Theme by Rowell Sotto.
 
© Harri