CWO++library  0.32
 All Classes Functions Variables Groups
CWO++library Documentation

Table of Contents

Introduction

Diffraction calculation, such as the angular spectrum method and Fresnel diffraction, are used in wide-ranging optics fields, ultrasonic, X-ray and electron beam to calculate scalar wave propagation. For example, in optics field, these calculations are useful for computer-generated holograms (CGHs), digital holography, the design of diffractive optical elements, microscopy, image encryption and decryption, three-dimensional analysis for optical devices and so on. We develop a C++ class library, which is referred to as Computational Wave Optics library for C++ (CWO++), for diffraction and useful auxiliary functions. The diffraction caluclations are Fresnel diffraction, angular spectrum method, scaled diffractions, tilted diffractions and so forth. This library can run on both CPUs and NVIDIA GPUs.

Author:
Tomoyoshi Shimobaba
Version:
CWO++ library ver 0.32
Date:
2011-2018

Features

Examples


This library is designed for easily programming wave optics phenomena. For example, the following sample code shows the calculation of a diffracted field using the angular spectrum method on a CPU.

CWO a;
a.Load("sample.bmp"); //load image file
a.Diffract(0.1, CWO_ANGULAR); //calculate diffraction from the image using the angular spectrum method
a.SaveAsImage("diffract.bmp",CWO_SAVE_AS_INTENSITY); //save the intensity of diffracted field as bitmap file
a.SaveAsImage("diffract.bmp",CWO_SAVE_AS_AMP); //save the amplitude of diffracted field as bitmap file
a.SaveAsImage("diffract.bmp",CWO_SAVE_AS_ARG); //save the argument (phase) of diffracted field as bitmap file
a.SaveAsImage("diffract.bmp",CWO_SAVE_AS_RE); //save the real part of diffracted field as bitmap file
a.SaveAsImage("diffract.bmp",CWO_SAVE_AS_IM); //save the imaginary part of fiffracted field as bitmap file

If you want to execute the above source code on a GPU, you only rewrite class CWO with class GWO as the following source code. Other code rewritings are not necessary. This feature improves portability from a CPU source code to GPU one. The data communication between a host computer and GPU is implicitly done by class GWO.

GWO a;
a.Load("sample.bmp"); //load image file
a.Diffract(0.1, CWO_ANGULAR); //calculate diffraction from the image using the angular spectrum method
a.SaveAsImage("diffract.bmp",CWO_SAVE_AS_INTENSITY); //save the intensity of diffracted field as bitmap file
a.SaveAsImage("diffract.bmp",CWO_SAVE_AS_AMP); //save the amplitude of diffracted field as bitmap file
a.SaveAsImage("diffract.bmp",CWO_SAVE_AS_ARG); //save the argument (phase) of diffracted field as bitmap file
a.SaveAsImage("diffract.bmp",CWO_SAVE_AS_RE); //save the real part of diffracted field as bitmap file
a.SaveAsImage("diffract.bmp",CWO_SAVE_AS_IM); //save the imaginary part of fiffracted field as bitmap file

You can also use the following sample code if you need explicitly data communication.

CWO a;
GWO g; //class for GPU
a.Load("sample.bmp"); //load image file
g.Send(a); //send the image data to the GPU
g.Diffract(0.1, CWO_ANGULAR); //calculate diffraction on the GPU
g.Intensity(); //calculate the light intensity on the GPU
g.Scale(255); // convert to 256 gray scale data on the GPU
g.Recv(a); //host computer receives the diffraction image
a.Save("diffract.bmp"); //save the intensity as bitmap file

The left and right images are the original image and diffracted image, respectively.

lena512x512_diffract.jpg

For more sample codes, please see example page.

Gallary

The following CGHs and the reconstructed images were obtained by CWO++ library.

white_asian_dragon.jpg

Reconstructed images from CGHs. (original data : The Stanford 3D Scanning Repository)

color_buddah.jpg

Reconstructed images from CGHs. (original data : S.Wanner, S. Meister, and B. Goldluecke, "Datasets and Benchmarks for Densely Sampled 4D Light Fields," Vision, Modeling & Visualization, 225?226 (2013))

Downloads

You can download this library from here.

Environment

Installation for Windows

Installation for Linux

Coming soon...

How to update new CWO++ library to existing code using the old version

If you have already used CWO++ library and want to update new version of CWO++ library, please overwrite the existing directory "src" and files "cwo.dll" "cwo.lib" "gwo.dll" and "gwo.lib" by the new version of them.

If you have problems...

Reference

Academic achievements using CWO++ library

Please contact me when you can obtain academic / commercial achievements using CWO library.