#############           Example Script                  ##########################
#                       for nona
#
# This document describes the script supported by the nona stitcher.
#
# Based on the PTStitcher documentation
#
#
# Only lines starting with 'p','o', i', 'm' or 'k' are read, 
# so you can add comments and info as you like by using 
# other line starting characters.  

# The stitcher script must contain:
# one 'p'-line describing the output image (eg Panorama)
# one 'i'-line for each input image
# one 'm'-line for global options
#
# 'p'-line options
# w1000        width in pixels
# h600         height in pixels
# f0           projection format,
#                  0 - rectilinear (for printing and viewing)
#                  1 - Cylindrical (for Printing and QTVR)
#                  2 - Equirectangular ( for Spherical panos), default
#                  3 - full-frame fisheye
#                  4 - Stereographic
#                  5 - Mercator
#                  6 - Transverse Mercator
#                  7 - Sinusoidal
#                  8 - Lambert Cylindrical Equal Area
#                  9 - Lambert Equal Area Azimuthal
#                 10 - Albers Equal Area Conic
#                 11 - Miller Cylindrical
#                 12 - Panini
#                 13 - Architectural
#                 14 - Orthographic
#                 15 - Equisolid
#                 16 - Equirectangular Panini
#                 17 - Biplane
#                 18 - Triplane
#                 19 - Panini General
#                 20 - Thoby Projection
#                 21 - Hammer-Aitoff Projection
# v360         horizontal field of view of panorama (default 360)
# nPICT        Panorama file format, one of:
#                  PNG           png-format, 8 & 16 bit supported
#                  PNG_m         png-format, multi-file, one image per file
#                                  alpha layer with non-feathered clip mask at image border
#                  TIFF          tiff-format, all tiff types supported (8,16,32 bit int, float, double)
#                  TIFF_m        tiff-format, multi-file, one image per file
#                                  alpha layer with non-feathered clip mask at image border
#                  TIFF_multilayer  tiff-format, multi-image-file, all files in one image
#                                  alpha layer with non-feathered clip mask at image border
#                                  This filetype is supported by The GIMP
#                  JPEG          Panoramic image in jpeg-format.
#                  JPEG_m        jpeg-format, multi-file, one image per file 
#                                  without alpha layer, not suitable for further blending or fusing
#               some more supported file formats (mostly only 8 bit support)
#                  PNM, PGM, BMP, SUN, VIFF
#                  
#              Special options for TIFF output:
#              n"TIFF c:NONE"              
#                  c - select TIFF compression, possible options: NONE, LZW, DEFLATE
#
#              Special options for TIFF_m and TIFF_multilayer output:
#              n"TIFF c:NONE r:CROP"
#                  c - TIFF compression, possible options NONE, LZW, DEFLATE
#                  r - output only used image area (cropped output). The crop offsets
#                      are stored in the POSITIONX and POSITONY tiff tags
#                  p1 - save coordinate images (useful for further programs, like vignetting correction)
#
#              Special options for JPEG output:
#              n"JPEG q95"
#                  q - jpeg quality
#                  
# E12.3        exposure value for final panorama
# R1           stitching mode: 0: normal LDR mode, 1: HDR mode
# T"UINT8"     bitdepth of output images, possible values are
#               UINT8  -  8 bit unsigned
#               UINT16 - 16 bit unsigned
#               FLOAT  - 32 bit floating point
#              By default the bit depth of the input images is use.
#
# S100,600,100,800   Selection(left,right,top,bottom), Only pixels inside the rectangle
#                    will be rendered. Images that do not contain pixels in this area
#                    are not rendered/created.
#
# k1           Image number of reference image for photometric correction
#
# P"100 12"    Parameters for tuning projection, number of parameters depends on projection
#
p w1000 h600 f0 v360 E12.3

# The 'i' lines describe input images (nona also accepts 'o' line image descriptions)
#
# f0           projection format,
#                  0 - rectilinear (normal lenses)
#                  1 - Panoramic (Scanning cameras like Noblex)
#                  2 - Circular fisheye
#                  3 - full-frame fisheye
#                  4 - Equirectangular (spherical panos)
#                  8 - orthographic fisheye
#                 10 - stereographic fisheye
#                 21 - Equisolid fisheye
#                 20 - Fisheye Thoby (Nikkor 10.5)
# v82          horizontal field of view of image (required)
# y0           yaw angle (required)
# p43          pitch angle (required)
# r0           roll angle (required)
# a,b,c        lens correction coefficients (optional)
#                  (see http://www.fh-furtwangen.de/~dersch/barrel/barrel.html)
# d,e          initial lens offset in pixels(defaults d0 e0, optional).
#                  Used to correct for offset from center of image
#                  d - horizontal offset,
#                  e - vertical offset
# g,t          initial lens shear.  Use to remove slight misalignment
#                  of the line scanner relative to the film transport
#                  g - horizontal shear
#                  t - vertical shear
#
# Eev          exposure of image in EV (exposure values)
# Er           white balance factor for red channel
# Eb           white balance factor for blue channel
#
# Vm           vignetting correction mode (default 5):
#                  0: no vignetting correction
#                  1: radial vignetting correction (see Va, Vb, Vc, Vd options)
#                  2: flatfield vignetting correction (see Vf option)
#                  4: proportional correction: i_new = i / corr.
#
#                      default is additive correction: i_new = i + corr

#                    Both radial and flatfield correction can be combined with the
#                     proportional correction by adding 4.
#                 Examples: Vm1 - radial polynomial correction by addition.
#                                 The coefficients Va, Vb, Vc, Vd must be specified.
#                           Vm5 - radial polynomial correction by division.
#                                 The coefficients Va, Vb, Vc, Vd must be specified.
#                           Vm6 - flatfield correction by division.
#                                 The flatfield image should be specified with the Vf option
#
# Va,Vb,Vc,Vd  vignetting correction coefficients. (defaults: 1,0,0,0)
#               ( 0, 2, 4, 6 order polynomial coefficients):
#                corr = ( i + j*r^2 + k*r^4 + l*r^6), where r is the distance from the image center
#              The corrected pixel value is calculated with: i_new = i_old + corr
#              if additive correction is used.
#              for proportional correction (Vm5): i_new = i_old / corr;
#
# Vx,Vy        radial vignetting correction offset in pixels (defaults Vx0 Vy0, optional).
#                 Used to correct for offset from center of image
#                  Vx - horizontal offset
#                  Vy - vertical offset
#
# Vf           filename of flatfield image.
#               For additive correction the image will be used as it is.
#               In the case of correction by division, the flatfield will be divided by
#               its mean value.
#
# Ra,Rb,Rc,Rd,Re EMoR photometric model parameters. (defaults: 0,0,0,0,0) 
#
# TrX,TrY,TrZ  mosaic mode translation offsets.
#
# Tpy, Tpp     orientation of remapping plane for translation offsets. 
#                (have no effect if TrX, TrY and TrZ are zero)
#
# S100,600,100,800   Selection(l,r,t,b), Only pixels inside the rectangle will be used for conversion.
#                       Original image size is used for all image parameters
#                       (e.g. field-of-view) refer to the original image.
#                       Selection can be outside image dimension.
#                       The selection will be circular for circular fisheye images, and
#                       rectangular for all other projection formats
#
# j0           stack number
#
# nName        file name of the input image.
#
#      Parameters in different images can be linked using '='
#      followed by the image number starting with 0.
#      Example 'v=0' sets horizontal field of view as in
#      image number 0. You can only refer to images before the 
#      current image.

i f2 r0   p0    y0     v183    a0 b-0.1 c0  S100,600,100,800 n"photo1.jpg"
i f2 r0   p0    y180   v183    a0 b-0.1 c0  S100,600,100,800 n"photo1.jpg"


# 'm'-line options
# ----------------
# Set mode for stitcher, not required
#
# i2           Set interpolator, See <http://www.fh-furtwangen.de/~dersch/interpolator/interpolator.html>
#                one of:
#                   0 - poly3 (default)
#                   1 - spline16,
#                   2 - spline36,
#                   3 - sinc256,
#                   4 - spline64,
#                   5 - bilinear,
#                   6 - nearest neighbor,
#                   7 - sinc1024
#                   
m i2


# 'v'-line options
# ----------------
# Indicate i-line parameters to optimise
# nona ignores all 'v' lines, these lines are used by autooptimiser
# (a,b,c,d,e,v,r,p,y geometric parameters) and vig_optimize
# (Eev,Er,Eb,Va,Vb,Vc,Vd,Vx,Vy,Ra,Rb,Rc,Rd,Re photometric parameters)
#
# Optimization variables are listed together with the image number
# starting at 0. There can be several v-lines.
#
# y0           Optimize yaw in image 0
# p1           Optimize pitch in image 1
# r2           Optimize roll in image 2
# v0           Optimize field of view in image 0
#
#      If a image has a parameter linked to another image only
#      need to optimize the master.
#
v v0 r0 p0 r1 p1 y1

# 'k'-line options
# ----------------
# Optional image masks are described by a 'k' line
#
#  i2           Set image number this mask applies to
#
#  t0           Type for mask:
#                   0 - negative (exclude region)
#                   1 - positive (include region)
#                   2 - negative, stack aware (exclude region from stack)
#                   3 - positive, stack aware (include region from stack)
#                   4 - negative, lens (exclude region from all images of same lens)
#
#  p"1262 2159 1402 2065 1468 2003"  List of node coordinates
#               Coordinates are in pairs, at least three pairs are required

k i2 t0 p"1262 2159 1402 2065 1468 2003"


# 'c'-lines
# ----------------
# Control point lines
# nona ignores all 'c' lines, these lines are used by autooptimiser
#
# One line per point pair
# about one pair of points per image per variable being optimized.
# The more variables being optimized the more control points needed.
#
# n0           first image
# N1           second image
# x1066.5       first image x point position
# y844.333      first image y point position
# X239.52       second image x point position
# Y804.64       second image y point position
# t0           type of control point (optional)
#                  0 - normal (default)
#                  1 - optimize horizontally only
#                  2 - optimize vertically only
#                  3+ (all other numbers) - straight line

c n0 N1 x1066.5 y844.333 X239.52 Y804.64 t0
