Here is an even better squeezed Panini script.  In fact this may be the one I have been seeking for the past 3 months.  Now I feel ready to start making serious architectural photos.

The main change from eqr_squeezedpanini.mm is that I dropped the "sqa" parameter (which I decided is nothing but a nasty distorted equivalent of pan) and added "tilt", which turns out to be very useful.  This is not your usual pitch control, that makes verticals lean in or out.  Rather, it is a kind of rotation around the point at infinity, that keeps verticals vertical.  It changes the appearance of horizontal lines and the vertical scale relations in ways that nicely complement the squeezed Panini functions.

Some examples of what I have been able to to with eqr_sqzpan2 are at
http://www.flickr.com/photos/26786650@N08/sets/72157622917319548/

I seem to get the best balance of pictorial qualities with the eye distance around 0.5 and sqz and sqw also around 0.5.  Tilt gives very sensitive control of the curvature of horizontals near view center.

The input format must be 360 x 180 degree equirectangular, even if the actual image is smaller than that.

Parameters:
  eyed:  the Panini eye distance, sets horizontal compression
  pan, zoom:  (if you have to ask, come back later)
  tilt: vertical perspective adjustment, see above
  hshf, vhsf:  align projected image in frame, as in Panini
  sqz:  sets squeeze strength from none (0) to full (1)
  sqw:  sets width of not-fully-squeezed areas

You will notice that "squeeze" actually seems to stretch the sides of the image vertically, rather than compress the center. But everything is relative, isn't it?

The squeeze width parameter sqw seems to work backward; it actually sets the width of the unsqueezed areas at the sides, and of the transition between squeezed and unsqueezed.  So 0 gives the biggest squeeze.


---- eqr_sqzpan2.mm ----

filter eqr_sqzpan2 (  
  image in,
  float eyed: 0-2 (1),
  float pan: -180-180 (25),
  float tilt: -30-30 (0),
  float zoom: 0.25-2 (.75),
  float hshf: -1-1 (0),
  float vshf: -1-1 (0),
  float sqz: 0-1 (1),
  float sqw: 0-1 (1)
)
##
#  360x180 equirect to squeezed panini with tilt
#  (c) copyright 2009 Thomas K Sharpless
#  free license is granted for noncommercial use
##

# parameters
Sppr = W / (2*pi);	# source pixels/radian
d = eyed + 1;
wfov = pi * 150 / 180;	# radians
Drpp = 2*d*tan(wfov/(2*d)) / W;
qtw = sqw * pi;
qwa = pi;
qwr = 0.5 * (qwa - qtw);
qwl = -qwr;
qsl = 1;
qsr = 1;
xshf = X * hshf;
yshf = Y * vshf;
Ta = tilt * pi /180;

# destination coordinates in radians
xr = (x - xshf) * Drpp / zoom; 
yr = (y - yshf) * Drpp / zoom;

# project dest to cylinder
azi = d * atan( xr, d );
fp = (eyed + cos(azi))/d;	# panini factor
fs = cos(azi);			# squeezed factor

# taper the squeeze factor
if azi > qwr then
  tt = max(0,min(1,(azi-qwr) / qtw ));
  fs = (tt) * qsr * fp + (1-tt) * fs; 
else if azi < qwl then
  tt = max(0,min(1,(qwl-azi) / qtw ));
  fs = (tt) * qsl * fp + (1-tt) * fs; 
end end;

# project linear mix of cyl. hgts to sphere
alt = atan( yr * (fp + sqz * (fs - fp)) );

# source coordinates in pixels
sx = Sppr*azi; 
sy = Sppr*( alt + Ta );

# pan and wrap
sx = sx + W*pan/360;
if sx > X then sx = sx - W end;
if sx < -X then sx = sx + W end;

#interpolate
in(xy:[sx, sy])

end


