ec2-3-239-95-36.compute-1.amazonaws.com | ToothyWiki | RecentChanges | Login | Webcomic

A very useful panoramic image stitcher program.

I (Admiral) have written a little script that will take a hugin project file and convert it into a graphviz dot file, for turning into a diagram, like one of these:

Image: 203

Except twice the size and without the JPEG compression artifacts. Then you can look at whether the source images are properly connected, or if there's some improvement to be made.

Code for the first script, called ptoToDot?, which converts a pto file to a dot file follows:


echo "graph project {"
echo "    splines=true;"
echo "    overlap=scale;"
echo "    sep=0.25;"
echo "    node [pin=true];"

grep "^i" $1 | grep -n "^i" | sed -e "s/^\([0-9]\+\):i .* p\([-.0-9]\+\) .* y\([-.0-9]\+\) .* n\"\(.*\)\.jpg\"$/print \"    \", \1 - 1, \" \[pos=\\\\q\3,\2\\\\q,label=\\\\q\", \1 - 1, \"\\\\q,shapefile=\\\\q.dot_thumbnails\/\4.png\\\\q,fontcolor=red,fontsize=50\]\\\\n\"/" | bc

grep "^c" $1 | sed -e "s/^c n\([0-9]\+\) N\([0-9]\+\) .*$/\1 \2/" | sort | uniq -c | sed -e "s/^ *\([0-9]\+\) \([0-9]\+\) \([0-9]\+\)$/    \"\2\" -- \"\3\" \[label=\1\];/"

echo "}"

Code for the second script, called ptoToPng? which creates the thumbnails and runs neato to produce the image follows:


if test -d ".dot_thumbnails" ; then
    echo "Thumbnails already present" >&2
    mkdir .dot_thumbnails
    for i in *.jpg ; do
        o=`echo $i | sed -e "s/jpg/png/"`
        if test "8" = "`jpegexiforient $i`" ; then
            jpegtopnm $i | pnmflip -ccw | pnmscale -reduce 16 | pnmtopng >.dot_thumbnails/$o
            jpegtopnm $i | pnmscale -reduce 16 | pnmtopng >.dot_thumbnails/$o

ptoToDot $1 | neato -Tpng -s10


I wasn't exactly told a while back that someone was working on getting this to do [DOF stacking] - has anyone had any success with that?  -- SGB

SGB: Is there a good measure of detail at a pixel? ISTR the liquid resize used gradient-magnitude; can I get GIMP to give me that as a layer?
MoonShadow: Your camera's autofocus will typically aim to maximise the difference in brightness between adjacent pixels. I am not aware of any other measurement. The problem is, the difference in brightness between pixels within a single image is meaningless as it depends on your subject. Really you want to start with a large set of images and find local maxima at each point, then select the appropriate image's pixel for that point.
SGB: I was hoping to set the alpha channel based on some measure of detail, then stack the images and flatten it; that way the in-focus bits should all be visible (and the rest should more-or-less agree anyway)
MoonShadow: Well, yes. But the per-image measure of detail is something you determine from the set of all the images, not just a single one. In a single image you can't tell out-of-focus from flatly-shaded.
SGB: I don't need to be able to tell out-of-focus from flatly shaded, though - if an area's flatly shaded, it should be the same in every image, focused or not.
MoonShadow: You have to start with at least one non-transparent image, then, but I guess...
MoonShadow: Thing is, if you just do that you're gonna get halos.
SGB: Some, yeah. I won't know to what degree until I try.
MoonShadow: Well, edge detection is well understood. Convolve your image with a Sobel matrix and set the alpha to the absolute value of the result
SGB: (also, in the images I want to try, I'm not trying to get unlimited DOF; just the highest DOF I can from the photos I have)
MoonShadow: If you square or cube the alpha, that will have the effect of biasing regions towards the image in which they are best focused and hopefully reduce the halos

ec2-3-239-95-36.compute-1.amazonaws.com | ToothyWiki | RecentChanges | Login | Webcomic
Edit this page | View other revisions | Recently used referrers
Last edited November 16, 2007 4:48 pm (viewing revision 7, which is the newest) (diff)