module OW_image
!
! Imaging Condition -- crosscorrelation
!

use OW_type
use OW_parms

implicit none

private					:: ni
integer					:: ni

contains

!---------------------------------------------------------
subroutine owimage_init(ni_in)

integer					:: ni_in

ni=ni_in

end subroutine
!----------------------------------------------------------
subroutine owimage(ws,wr,GG) 

integer					:: ish, ihso, ixw
complex					:: GG(:,:),wr(:),ws(:)

do ish=1,img%sh%n
   ihso=floor(((ish-1)*img%sh%d+img%sh%o)/(img%xm%d))
   do ixw=1,rec%h%n
      if (ixw-ihso < 1 .or. ixw-ihso > rec%h%n .or. ixw+ihso < 1 .or. ixw+ihso > rec%h%n) then
      else
          GG(ish,ixw)=GG(ish,ixw)+conjg(ws(ixw-ihso))*(wr(ixw+ihso))             ! correlation to produce an image
      end if
   end do
end do

end subroutine

end module
