The GWO library easy documantation
(written by Tomoyoshi Shimobaba @ Yamagata University, Japan)
optics, several diffraction integrals, such as the angular spectrum
method and the Fresnel diffractions, are used for calculating scalar
The calculation result provides us with the
optical characteristics of an optical device, the numerical
reconstruction image from a hologram, and so forth.
acceleration of the calculation commonly uses the fast Fourier
transform; however, in order to analyze a three-dimensional
characteristic of an optical device and compute real-time
reconstruction from holograms, recent computers do not have sufficient
The GWO (GPU-based Wave Optics)
library is numerical calculation library for the diffraction integrals
using a GPU (Graphics Processing Unit). If optics engineers and
researchers have no knowledge of GPU, the GWO library provides them
with the GPU calculation power easily.
You can download the GWO library from http://sourceforge.net/projects/thegwolibrary/
The system requirements of the GWO library are as follows:
(1) Operating system : Windows XP
(2) NVIDIA CUDA version : 2.0 (please download here)
(3) NVIDIA GPU (Geforce8800 higher)
The installation of the GWO library is as follows:
(1) Please place the GWO files (gwo.dll, gwo.h, gwo.lib) on your project directory.
(2) Please register gwo.h and gwo.lib to your project.
If you have any problem or want to add a new function to the library,
please feel free to contact me.
Sample code using the GWO library (1)
We show a sample code in order to calculate diffraction.
#define WIDTH 1024
#define HEIGHT 1024
#define WIDTH2 (WIDTH*2)
#define HEIGHT2 (HEIGHT*2)
float gwo_max=0.0, gwo_min=0.0;
//gwoComplex is the complex number.
//if you use to the real part of gwoComplex, please use GWO_RE(...).
//if you use to the imaginary part of gwoComplex, please use GWO_IM(...).
unsigned char pix[WIDTH*WIDTH];
//Prepare an aperture with 20*20 pixel.
j<WIDTH/2+10 && >HEIGHT/2-10 && i<HEIGHT/2+10)
//Initialize the library.
gwoInit(GWO_ANGULAR,WIDTH2,HEIGHT2); //if you calculate the Angular spectrum
//gwoInit(GWO_FRESNEL_CONV,WIDTH2,HEIGHT2);//if you calculate the Fresnel difraction(convolution type)
//gwoInit(GWO_SHIFTED_FRESNEL,WIDTH2,HEIGHT2);////if you calculate the Shifted-Fresnel difraction
//Expands the original aperture (ape_small).
//The expanded aperture (ape) has double size as compared with the original aperture.
//Set the sampling spacing (4.65 um) on the aperture and the diffracted plane.
//Set the wavelength (633nm).
//Send the expanded aperture to the GPU.
//Calculate the diffraction with the propagation distance of 0.2m.
//If you need the light intensity of the diffracted light,
//please execute gwoIntensity().
//If you do not need the light intensity,
//please comment out gwoIntensity();
//The host computer receives the calculated result (the diffracted result).
//Reduce the expanded aperture (ape) to the buffer (result).
//Search the maximum and minimum value in the buffer (result).
//Convert the light intensity to 256 monochrome image.
unsigned char c=(unsigned char)(255.0*(tmp-gwo_min)/gwo_max));
//Finalize the library.
Sample code using the GWO library (2)
We show a sample code in order to calculate a CGH (computer-generated-hologram) from an object with 1 point .
The calclulation using the GWO library can calculate a CGH faster than a personal computer.
The GWO library adopted CGH calculation methods by the followinf references:
Ito, N. Masuda, K. Yoshimura, A. Shiraki, T.
Shimobaba, and T. Sugie, "Special-purpose computer HORN-5 for a
real-time electroholography," Optics Express 13, 1923-1932 (2005)
Shimobaba, Atsushi Shiraki, Yasuyuki Ichihashi, Nobuyuki Masuda and
Tomoyoshi Ito, "Interactive color electroholography using the FPGA
technology and time division switching method", IEICE Electronics
Express (ELEX), Vol.5, No.8, pp.271-277 (2008)
Shimobaba, Sinsuke Hishinuma and Tomoyoshi Ito, "Special-Purpose
Computer for Holography HORN-4 with recurrence algorithm", Computer
Physics Communications., No.148/2, pp. 160-170 (2002)
Shimobaba and Tomoyoshi Ito, "An efficient computational method
suitable for hardware of computer-generated hologram with phase
computation by addition", Computer Physics Communications., Vol
138, pp. 44-52 (2001)
- Tomoyoshi Shimobaba, Nobuyuki Masuda,
Takashige Sugie, Satoru Hosono, Shinobu Tsukui, Tomoyoshi Ito,
"Special-Purpose Computer for Holography HORN-3 with PLD
technology", Computer Physics Communications., Vol. 130, pp.
#define CGH_W 1024
#define CGH_H 1024
gwoObjPoint *obj=new gwoObjPoint[num];
float *hol=new float[CGH_W*CGH_H];