ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/fisheye_corr.cal
Revision: 1.1
Committed: Mon Aug 1 00:08:38 2016 UTC (7 years, 10 months ago) by greg
Branch: MAIN
Log Message:
Added file to correct fisheye lens perspective

File Contents

# User Rev Content
1 greg 1.1 { RCSid $Id$ }
2     {
3     Correct fisheye image using a distortion function:
4    
5     rad(r) = function of r in [0,.5] range, returing same
6    
7     This function takes the pixel distance from the image center, where
8     1.0 is the full width of the image constituting 180-degrees of view.
9     The output is the corrected distance from the center for the output.
10    
11     pcomb -e 'rad(r)=my_function(r)' -f fisheye_corr.cal \
12     -o fisheye.hdr > corrected.hdr
13    
14     We also clear the region outside the r=[0,.5] circle to black.
15    
16     Note that you will need to add back the VIEW= line to the header, e.g.:
17    
18     echo "VIEW= -vta -vh 180 -vv 180" > corrected.hdr
19     (above_command) >> corrected.hdr
20     }
21     xc : xres/2;
22     yc : yres/2;
23     sq(x) : x*x;
24     r = sqrt(sq((x-xc)/xres) + sq((y-yc)/yres));
25     mapped_r = rad(r);
26     { If your mapping goes the other way, invert the multiplier with:
27     rmult = r/(mapped_r+1e-7);
28     }
29     rmult = mapped_r/(r+1e-7);
30     xoff = (x-xc)*(1-rmult);
31     yoff = (y-yc)*(1-rmult);
32     ro=if(.5-mapped_r, ri(1,xoff,yoff), 0);
33     go=if(.5-mapped_r, gi(1,xoff,yoff), 0);
34     bo=if(.5-mapped_r, bi(1,xoff,yoff), 0);