Automatic Processing of Movies with caccord

For the best drift-corrected results one needs a high number of very quickly acquired SEM images. Many current SEMs allow for acquiring a sequence of images in a video file. This may be the best way to obtain large series of quickly following images. This guide shows how to easily and automatically process videos/movies files form the SEMs with ACCORD producing a drift-corrected SEM image and the displacement trajectory. ACCORD cannot work directly with videos, but using the following script, it is fairly easy to process videos as well.

The procedure to process videos with caccord (the console version of ACCORD):

  • Acquire your video from the SEM.
    • Use shortest possible dwell time. (Beware of non-working fast acquisition modes, where you e. g. see “dashes” instead of “dots” in the image.)
    • Do not use any averaging/integration.
    • Avoid rescaling and lossy compression.
    • Keep your sample stationary. Do not disturb the instrument. Do not talk, open or slam doors, do not let your telephone ring, etc.
  • Save the obtained .avi file.
  • Create a dedicated directory/folder on your workstation and copy the .avi file there.
  • Download the script below and copy it to the same directory.
  • Run the script with the corresponding parameters. Example:

sh accord_video.sh video.avi rit

  • Then you find your results in the out direcotry.
    • rit_disp.txt is a text file. Its format is: index; x-displacement, y-displacement. The latter two values are in pixels.
    • rito.tiff is the drift-corrected image. The format of this file is the 8-bit uncompressed TIFF.

This script has been tested under Linux and should work under other UN*X systems or Cygwinned Windows as well.

accord_video.sh
#!/bin/bash
 
# LICENSE
#
# Copyright (c) 2012, Dr. Petr Cizmar @ Physikalisch-Technische Bundesanstalt,
#                                       Braunschweig, Germany
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the <organization> nor the
#       names of its contributors may be used to endorse or promote products
#       derived from this software without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
######################################################################################
 
 
# ATTENTION!
# 
# It's recommended to run this script from a dedicated directory. Numerous
# output files will be dumped to the working direcotry.
#
 
 
# TWEAK THE FOLLOWING VALUES TO SUIT YOUR INSTRUMENT AND SYSTEM CONFIGURATION:
 
CROPBOTTOMPIX=73     # Number of pixels to crop from the bottom.
#CACCORD=$HOME/work/sw/accord/build/src/caccord
CACCORD=caccord
FFMPEG=ffmpeg
 
if [ x"$2" = x"" ] 
then
  echo "Usage: $0 movie_from_SEM.avi output_file_name_base"
  exit 99
fi
 
AVI=$1
BASE=$2
[ -f $AVI ] || { echo "$AVI is not a file."; exit 99; }
 
[ -x $FFMPEG -o -x $(which $FFMPEG) ] || { echo "Cannot find ffmpeg binary."; exit 89; }
$FFMPEG -i $AVI ${BASE}_%03d.tiff
 
[ -d $PWD/out ] || mkdir $PWD/out
 
cat << EOF > $BASE.acc
#!/usr/bin/env caccord -c
 
#This is an ACCORD configuration file.
# see http://accord.sf.net.
 
 
 
[config]
output path: $PWD/out
output prefix: ${BASE}o
traditional: no      #yes for plain averaging. Default: no
all images: no      #yes if all sum images should be saved. Default: no
full weight normalize: yes       #yes if only full-weight pixels determine the norm. Default: yes
 
crop top: 0
crop bottom: $CROPBOTTOMPIX
crop left: 0
crop right: 0
 
 
[input files]
EOF
 
ls $PWD/$BASE*.tiff >> $BASE.acc
 
[ -x $CACCORD -o -x $(which $CACCORD) ] || { echo "Cannot find cACCORD binary."; exit 88; }
$CACCORD -c $BASE.acc
automatic_processing_of_movies.txt · Last modified: 2012/02/14 09:27 by petrcizmar
Back to top
Public Domain
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0