Data Preparation

Batch Image Segmentation + Edge Filter Preparation Script

The script requires the following to be installed and in path:

This script is EXTREMELY slow and will need to be revamped. It is also slightly different from my original script, but should work quite well, I think.

convert video to image sequence

ffmpeg -i video.mpg image%d.jpg

prepimage2.sh - much faster segmentation script. may need some tweaking to find optimal results. uses graph-based segmentation code (link).

#!/bin/bash

#mkdir -p original
#mkdir -p prepped
intfile="prepped/temp.ppm"
intfile2="prepped/temp2.ppm"

for nam in *.jpg; do
  if [ -f "$nam" ]; then
    outfile="`basename "$nam" .jpg`.png"
    outppm="`basename "$nam" .jpg`.ppm"
    outfile1="original/$outfile"
    outfile2="prepped/$outfile"
    echo "Working on file: $nam ($outfile)"

    convert "$nam" "$outfile1"
    convert "$nam" "$intfile"
    # 0.5 500 20
    ./segment 0.5 200 20 "$intfile" "$intfile2"
    convert "$intfile2" "$outfile2"
  fi
done

prepimage.sh

#!/bin/bash

for nam in *.jpg; do
  if [ -f "$nam" ]; then
    out="`basename "$nam" .jpg`.bmp"
    echo "Working on file: $nam ($out)"

    ./GREYCstoration_pc_linux -restore "$nam" -o "$out" -visu 0 -quality 100 -verbose 0 -sharp 1 -se 0.75 -dt 60 -p 0.7 -a 0.3 -alpha 0.6 -sigma 1.1 -prec 2 -dl 0.8 -da 30 -interp 0

    gimp -i -b '(vcam-prep-image "$out")' -b '(gimp-quit 0)' > /dev/null 2> /dev/null

    convert -segment 10x5 -edge 1 "$out" "$out"
  fi
done

vcam-prep-image.scm

(define (vcam-prep-image filename)
  (let* (
      (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
      (drawable (car (gimp-image-get-active-layer image)))
    )    
    (script-fu-Eg-SmartSharpen image drawable
      2.00 1.00 0.00 TRUE 5.00 1.00 0.00 0.50 0.01 6.00 6.00 TRUE
    )
    (set! drawable (car (gimp-image-merge-visible-layers image 0)))
    (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
    (gimp-image-delete image)
  )
)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License