subroutine space_correction
real:: H1 ! Distance between the camera and the water surface unit : cm
real:: H2 ! Distance between the water surface and the laser sheet unit : cm
real,dimension(2),intent(in):: X0 ! Position on the image ie on the water surface in PIXEL unit
real,dimension(2)::Xi ! Translation for initial calibration :)
real,dimension(2):: X1 ! Position on the image ie on the surface 1 ( water ) INPUT in cm unit
real,dimension(2),intent(out):: X2 ! Position in the real space ie at the laser sheet level OUTPUT
real,dimension(2)::teta,beta ! tmp angles
real::n1,n2 ! indice for the air and the water
integer::KXORD,KYORD,NXOUT,NYOUT
real,dimension(:)::XKNOT,YKNOT,BSCOEFX,BSCOEFY
integer,dimension(2)::sym_flag
!loading spline coefficients
open(unit=9,file='nikon50mm.splinecoef',form='binary',status='replace')
read(9) KXORD,KYORD,NXOUT,NYOUT
allocate(XKNOT(KXORD+NXOUT),YKNOT(KYORD+NYOUT),BSCOEFX(NXOUT*NYOUT),BSCOEFY(NXOUT*NYOUT))
read(9) XKNOT,YKNOT,BSCOEFX,BSCOEFY
close(9)
! Xi is the translation of the relative space for the splined and the center of the image.
Xi(1)=BS2VL(511.5,511.5,KXORD,KYORD,XKNOT,YKNOT,NXOUT,NYOUT,BSCOEFX)
Xi(2)=BS2VL(511.5,511.5,KXORD,KYORD,XKNOT,YKNOT,NXOUT,NYOUT,BSCOEFY)
sym_flag=1
X1(1)=BS2VL(X0(1)-1.,X0(2)-1.,KXORD,KYORD,XKNOT,YKNOT,NXOUT,NYOUT,BSCOEFX)
X1(2)=BS2VL(X0(1)-1.,X0(2)-1.,KXORD,KYORD,XKNOT,YKNOT,NXOUT,NYOUT,BSCOEFY)
X1=X1-Xi
! X1 is now the position in cm from the image center if we were at the bottom of the tank and without water .
X1=X1*H1/466.*20 ! the unit in the spline is 20 cm.
! X1 is now the distance between the image center and the point if it was at the water surface .
teta=atan(X1/H1)
beta=asin(n1/n2*sin(teta))
X2=tan(beta)*H2+X1
deallocate(XKNOT,YKNOT,BSCOEFX,BSCOEFY)
end subroutine space_correction