arXiv:1709.07223v1 [] 21 Sep 2017

Convolutional neural networks that teach
microscopes how to image

Roarke Horstmeyer∗
Biomedical Engineering Department
Duke University
Durham, NC
roarke.horstmeyer@gmail.com
Barbara Kappes
Institute of Medical Biotechnology
University of Erlangen-Nuremberg
Erlangen, Germany
barbara.kappes@fau.de

Richard Y. Chen
Y Combinator Research
San Francisco, CA
richard.chen@ycr.org

Benjamin Judkewitz
NeuroCure Cluster of Excellence
Charité–Universitätsmedizin Berlin &
Humboldt University, Berlin, Germany
benjamin.judkewitz@charite.de

Abstract
Deep learning algorithms offer a powerful means to automatically analyze the
content of medical images. However, many biological samples of interest are
primarily transparent to visible light and contain features that are difficult to resolve
with a standard optical microscope. Here, we use a convolutional neural network
(CNN) not only to classify images, but also to optimize the physical layout of the
imaging device itself. We increase the classification accuracy of a microscope’s
recorded images by merging an optical model of image formation into the pipeline
of a CNN. The resulting network simultaneously determines an ideal illumination
arrangement to highlight important sample features during image acquisition, along
with a set of convolutional weights to classify the detected images post-capture.
We demonstrate our joint optimization technique with an experimental microscope
configuration that automatically identifies malaria-infected cells with 5-10% higher
accuracy than standard and alternative microscope lighting designs.

1

Introduction

Artificial neural networks (ANNs) are now commonly used for image classification [1], segmentation [2], object detection and image resolution enhancement [3]. Convolutional neural networks
(CNNs) in particular continue to offer significant improvements over other supervised learning
techniques. While the growing field of deep learning has seen a lot of progress over the past several
years, most learning networks are trained on pre-captured datasets that contain standard images (e.g.,
MNIST [4], CIFAR-10, or BBBC [5]). Little work with ANNs and CNNs has jointly considered
how the image data that they process is actually acquired - that is, whether a particular camera setup,
illumination geometry or detector design might improve certain image post-processing goals.
In many scenarios, and in optical microscopy in particular, the various physical parameters used to
obtain an image are extremely important. For example, one must select an appropriate microscope
objective lens that fits the entire area of interest within its field-of-view, but also still resolves
important features of interest. Or, primarily transparent samples are often hardly visible at all
under a standard bright-field microscope. Alternative techniques like phase-contrast or differential
∗
Current address: NeuroCure Cluster of Excellence, Charité–Universitätsmedizin Berlin & Humboldt
University, Berlin Germany

CNN

Classifier:

(a) Bright-field
(1 image)

(b) FP
(29 images)

(c) Learned
(2 images)

Illumination design

(0) Not
infected

(1) Infected
with malaria
parasite
1

0

Classification:

Challenging

π

0.5

-1

Possible

Current work

…
LED
Illumination:

…
Fixed

Scanned

Learned

Figure 1: We use a convolutional neural network to jointly optimize the physical layout of microscope
illumination as well as a classifier to determine if cells are infected by the malaria parasite. The
classification accuracy with images from our optimal illumination technique in (c) notably exceeds that
for a standard bright-field imaging setup in (a). Alternative schemes like Fourier ptychography (FP,
complex-valued reconstruction in b) can improve spatial resolution for better subsequent classification,
but must capture more images and are thus less efficient. Scale bar: 2 µm.

interference contrast microscopy are typically used improve sample visibility. Likewise, more recent
computational approaches can also create sharper images by using structured illumination [6, 7, 8].
However, it is not clear which type of microscope design, illumination setting, or computational
optics-based approach might yield the best results for a particular CNN-driven task.
Here, we try to close the gap between how images are acquired and how they are post-processed
by CNNs. We include a model of optical image formation into the first several layers of a neural
network, which allows us to jointly optimize the design of a microscope and the various weights
used for image classification in one step, thus forming a specific type of “classification microscope."
As an experimental demonstration, we jointly determine an optimal lighting pattern for red blood
cell imaging as well as a CNN classifier to test for infection by the malaria parasite (Plasmodium
falciparum). By simply displaying two particular patterns on an LED array placed beneath our
microscope, we can increase infection classification accuracy by 5-10%. We are hopeful that the
presented framework will help bring together the growing field of deep learning with those who
design the cameras, microscopes and other imaging systems that capture the training data that most
learning networks currently use.

2

Related work

Deep learning networks for conventional [9] and biomedical [10] image classification are now
commonplace and much of this recent work relies on CNNs. However, as noted above, most studies
in this area do not try to use deep learning to optimize the acquisition process for their image data
sets. While early work has shown that simple neural networks offer an effective way to design
cameras [11], one of the first works to consider this question in the context of CNN-based learning
was presented recently by Chakrabarti [12], who designed an optimal pixel-level color filter layout
for color image reconstruction that outperformed the standard Bayer filter pattern.
Subsequent work has also considered using CNNs to overcome the effects of camera sensor noise [13]
as well as optical scattering [14, 15]. CNNs paired with non-conventional camera architectures
can additionally achieve light-field imaging [16, 17] and compressive image measurement [18].
Alternative imaging setups have also been coupled with supervised learning methods for cell imaging
and classification [19, 20]. The above works are some of the first to consider how the performance of
2

u

h

…

(a)

D[abs( )2 ]

oj

…

Classification

CNN postprocessing

Physical model
oj

(b)

u
D[abs( )2 ]

conv(h)

Input
object
(complex)

(c)

i1

i2

…

Illumination Convolution
weights
response
(complex)

…
Layer 1

…

Layer
N-1

Layer
N

(complex)

32

x'j

iL
w

Layer 2

64

1024
2

Σ

1x1xL

…
LED-illuminated
sub-images

LED
weights

Detected
image

Conv (5x5)
+ ReLU +
MaxPooling

Conv (5x5)
+ ReLU +
MaxPooling

FCL+ Readout
ReLU
(1024)

Figure 2: Physical CNN (P-CNN) for improving image classification accuracy. (a) Standard imaging
setup with variables of interest labeled, followed by a digital CNN. (b) P-CNN pipeline. Physical
layers (here including illumination, PSF convolution and detection) are in red while post-processing
layers are in blue. (c) Discretized physical CNN (DP-CNN) network used in simulations and
experiments. Each sub-image, under illumination from a unique direction, is weighted and summed
to form the final detected image that then enters a CNN classifier. Learned LED weights from the
physical layer specify the optimal illumination design for our classification microscope.

supervised learning in general and CNNs in particular connect to the exact procedure for optical data
acquisition. But, with the except of Chakrabarti’s work, they do not directly consider using the CNN
itself to optimize the detection process of an optical (or digital) device.
In this work, we first merge a general model of optical image formation into the first layers of a CNN.
After presenting our "physical CNN" model, we then present simulations and experimental results
for improved classification of cells from microscopic images. We focus on the particular task of
classifying if red blood cells are infected with the Plasmodium falciparum parasite, which is the most
clinically relevant and deadly cause of malaria. This goal has been examined within the context of
machine learning [19, 21] and CNNs [22] in the past. Unlike prior work, we demonstrate how our
physical CNN can simultaneously predict an optimal way to illuminate each red blood cell. When
used to capture experimental images, this optimized illumination pattern produces better classification
scores than tested alternatives, which hopefully can be integrated into future malaria diagnostic tools.

3

Image formation and network layers

In a typical imaging scenario, light first travels from a source to a scene of interest, physically interacts
with objects within the scene, and then propagates through a lens and to a sensor to form an image.
Here, we will model these physical processes in the early “physical" layers of a neural network,
which will then be followed by a series of standard "post-processing" network layers. In this work
we design the post-processing layers for image classification, but they could also be easily guided
towards other standard tasks (e.g., segmentation or object detection). After network optimization, the
physical-model weights, associated with the experimental parameters used to capture each image,
can then directly inform an optimized optical device design.
3

In a standard image-based CNN, inputs take the form of pre-recorded incoherent intensity images.
Each input image xj , for j = 1 to J training images, then passes through a number of network layers.
In each early network layer, 3 simple operations are typically applied in a repeated manner (e.g.,as
used in the early 5-layer LeNet [4], the more recent AlexNet [23], and many others since). The
first operation is a convolution, the second is a non-linear activation function L, and the third is a
down-sampling operation D. We may write these three steps as,
x0j = D [L [xj ? h]] ,

(1)

where x0j is the layer output, h is the convolution kernel and ? denotes convolution. A common
choice for the non-linear operation L is a rectified linear unit (ReLU) and a common choice for the
downsampling step D is max-pooling.
Here, we take a step back and first consider how light behaves before forming an image. Let’s consider
the simplified imaging system in Fig. 2(a) that we assume collects images for a classification task.
In this simple scenario, let’s assume that the object of interest is thin, which allows us to model its
optical response with a complex vector oj . Furthermore, we’ll assume that our object is illuminated
with spatially coherent light source (e.g., from a small source like an LED, as is often the case in a
microscope, although it is direct to model any other type of light). If we label our illumination field u,
then we can approximate the resulting optical field that is reflected off and/or transmitted through the
thin object as an element-wise multiplication between two complex vectors: xj = u · oj .
After emerging from the object, the optical field xj will then propagate to the imaging system (e.g.,
the camera lens in Fig. 2(a) or a microscope objective lens). A portion of this field will pass through
the lens and eventually reach a digital detector comprised of an array of pixels, which detects and
discretizes the intensity of the field. It is very common to model the linear process of image formation
as a convolution of the optical field at the object plane with a camera-specific point-spread function
(PSF), h [24]. The detector then measures the squared magnitude of the resulting convolved field. If
we summarize the discretization (i.e., locally averaging) caused by the finite size of each pixel with a
pixel sampling function P , then the entire image formation process takes the following form:
h
i
2
x0j = P |xj ? h| .
(2)
Here, xj = u · oj is the product of the illumination light with the object and x0j is the resulting image.
For a square pixel array with a full fill-factor, P is approximately equivalent to an average pooling
operation. Comparing Eq. 1 with Eq. 2, we see that image formation is nearly identical to an early
CNN layer. The two models are equivalent when 1) the CNN layer’s non-linear activation function L
is an absolute value squaring such that ∀x, L(x) = |x|2 (equivalent to a leaky ReLU function with
parameter α = −1) and 2) the downsampling operation D is average pooling.
Given the similarity between Eq. 1 and Eq. 2, we hypothesize that Eq. 2 is a natural fit for the first
layer of a CNN whose inputs are representations of physical objects (as opposed to their images).
While the weights within subsequent layers may be dedicated to computational operations for a
particular classification task, weights within this early "physical model" layer directly connect to
experimental parameters like the illumination field u, the camera’s point-spread function h and the
downsampling function P . After network optimization, they may inform a better imaging setup
and measurement process to achieve a particular CNN-related task. In the next section, we will
focus our attention on optimizing the illumination field u to improve image classification, but this
framework generalizes to optimizing both other optical parameters in Eq. 2 (h and P ) and other
optical parameters of interest (e.g., illumination wavelength, polarization, camera/lens location).

4

Optimal illumination for classification

Here, we first explain the P-CNN model in Fig. 2(b) in more detail and then discuss the particular
network used in our experiments (Fig. 2(c)). Let’s assume the jth input into our P-CNN is a complex
N × N matrix oj describing the jth sample of interest (e.g., a cell or collection of cells under a
microscope that we want to classify). Under the thin sample approximation, the sample absorption is
represented by its modulus |oj | and the sample phase response, which is typically directly proportional
to its thickness, is represented by its argument arg (oj ). The coherent illumination field u is modeled
as an N × N complex matrix of unknown illumination weights (assuming it can take any desired
shape), and as noted above the field emerging from the sample, xj in Eq. 2, is an element-wise
4

(b) LED-illuminated intensity image sets

(a)
1
Int. (AU)

SubImage ij,l

i1,2

i1,1

i2,1

i2,2

…

0

+7° LED

…

+14° LED

+7° LED

j=1: "Three"
2.5 µm

LED
weights w

j=2: "Five"

o1

o2

height

Sample oj

+14° LED

w l , kl

…

0
10 µm

10 µm

(c) Example transparent samples (thickness)

(d)

Center

Random

Off-axis

All

DPC

Optimized

?
Figure 3: (a) Simulated microscope setup. (b) 2 out of 25 example intensity images are displayed for
2 unique image sets. Each image (per set) is illuminated from a unique LED angle. (c) Example transparent objects created from the MNIST dataset and used to generate images in (b). (d) Illumination
patterns used for classification tests (optimized pattern determined via DP-CNN learning).
product of oj and u. To transform xj into a detected image, we then perform a convolution with
a complex point-spread function h (1 filter, stride = 1) and an element-wise vector squaring and
down-sampling, which simulates x0j in the P-CNN’s first physical layer (Fig. 2(b), red). Any standard
convolution-based classification network (Fig. 2(b), blue) can follow this first layer.
After network optimization, the learned N × N weights in u specify the optimal magnitude and
phase of an optical field to illuminate a sample with for subsequent classification. Since patterned
illumination can provide better image contrast, highlight features of interest and shift higher spatial
frequencies into a camera’s finite frequency passband, we hypothesize that images formed under
optimal physical illumination can be classified more accurately by the P-CNN post-processing layers
than those formed by alternative illumination strategies.
While in practice one could physically shape the optimal field u using an N × N pixel spatial light
modulator, we instead choose to work with the alternative imaging setup sketched in Fig. 3(a). Here, a
discrete set of LEDs from an array define our sample illumination. Each LED in the array illuminates
the sample with a coherent plane wave from a unique angle. Since the LEDs are mutually incoherent
with one another, the resulting image from multiple LEDs emitting simultaneously is the incoherent
sum of each LED-illuminated
“sub-image". If we have L LEDs within the array, each emitting a field
√
with magnitude wl for l = 1 to L, then we may write the jth detected image as the incoherent sum,
x0j =

L
X

(oj ·

√

wl eikl ·r ) ? h

l=1

2

=

L
X

wl ij,l .

(3)

l=1

√
Here, wl eikl ·r describes the lth LED-generated plane wave with intensity wl , traveling at an angle
specified by the transverse wavevector kl with respect to the optical axis. After each plane wave
illuminates the object oj , it is then blurred by the imaging system (coherent point-spread function
h) to form the lth sub-image of the jth object, ij,l . The weighted sum of these sub-images, where
the weight wl specifies the lth LED brightness, forms the detected image under illumination from a
particular LED pattern, x0j . This image then enters a digital classification pipeline. We refer to this as
the discretized physical CNN (DP-CNN) architecture, summarized in Algorithm 1.
For training, the DP-CNN simply requires the set {ij,l }L
l=1 of L uniquely illuminated images of each
object of interest as input. After optimizing the LED weight vector w for a particular classification
task, its values then specify how to simultaneously illuminate each future sample of interest with
5

Algorithm 1 Discretized Physical CNN (DP-CNN)
1: Input: {ij,l } with l ∈ {1, . . . , L} uniquely illuminated images of each object, object labels {yj }.
Number of iterations T . An image classification model F parametrized by θ.
2: Randomly initialize the LED weights w = {wl }L
l=1 .
3: for iteration t = 1 . . . , T do
4:
Sample a minibatch of ({ij,l }L
l=1 , yj ),
5:
Generate the detected images {x0j } according to Eq. 3,
6:
Take a gradient descent step on CrossEntropy(F (x0j ), yj ) with respect to w and θ.
7: end for
8: Output: the optimized LED weights w and the model parameters θ.
Table 1: Simulation results, MNIST phase digit classification with DP-CNN
Noise Level

Center

All

Off-axis

Random

DPC

Optimized

None (σ=0)
Low (σ=0.025)
High (σ=0.1)

0.378
0.362
0.367

0.975
0.973
0.971

0.974
0.974
0.967

0.975
0.972
0.970

0.974
0.974
0.972

0.983
0.983
0.981

Average

0.369

0.973

0.972

0.972

0.973

0.982

the LED array for improved classification. Each single optimally illuminated image will then enter
the post-processing classification layers of the trained DP-CNN pipeline (blue layers in Fix. 2(c)),
since the red layers of the DP-CNN have already been physically realized during image recording.
By illuminating the sample at a wide range of angles, we are able to physically shift around the
sample spectrum (i.e., the Fourier transform of the sample function oj ) to capture a wide range
of its spatial frequencies and thus a lot of diverse information that would otherwise not enter the
camera or microscope. In simulation and experiment, we illuminate from angles that are both less
than and greater than the maximum acceptance angle of our microscope objective lens to form both
bright-field and dark-field images of each sample. As we will show next, the classification accuracy
for DP-CNN-optimized images exceeds alternative illumination approaches.

5

Simulation results

To test whether the DP-CNN leads to an improved classification microscope design, we first simulate
a realistic imaging scenario. Many microscopic samples of interest are primarily transparent and
are thus challenging to capture clear images of under standard illumination. The first step in our
simulation is to generate many different transparent “samples" that we would like classify. To do
so, we use a standard classification dataset, the MNIST handwritten digit image set [4], and treat
each normalized MNIST image gj (x, y) as the height profile map of a thin, optically clear object.
Conceptually, this is equivalent to assuming that instead of being written in ink, each digit was
pressed into a clear plastic sheet.
Under the thin object approximation, we may express the phase delay of normal incident light that
passes through each of these transparent digit sheets as ∆φj (x, y) = 2πntgj (x, y)/λ, where n is the
medium’s refractive index, t is the maximum height variation, and λ = 500 nm is the wavelength
of quasi-monochromatic illumination. We also make the realistic assumption that the sample is not
100% transparent by defining a small amount of absorption as Aj (x, y) = αgj (x, y) with constant
α = 0.01. The optical field that would emerge from the sample under flat plane wave illumination,
oj (x, y), is then expressed as the complex function oj (x, y) = Aj (x, y)exp(i∆φj (x, y)).
It is possible to directly use the sample responses oj (x, y) and their associated labels yj ∈ (0–9)
as training/testing inputs for the P-CNN in Fig. 2(b). To test the DP-CNN in Fig. 2(c), we must
first simulate uniquely illuminated images of each object with Eq. 3. For each of j = 1 to 60,000
transparent digits described by oj , we simulate 25 different microscope images, ij,l , by turning on
each of the l = 1 to 25 LEDs in a 5 × 5 square array located beneath the sample plane (one LED at a
time). We assume each sample has an index of refraction n = 1.2, is at a maximum t = 2.5 µm thick,
is 40 × 40 µm in size and is discretized into 1.25 µm pixels. We use a 5X microscope objective with a
0.175 numerical aperture (NA) for simulated imaging and we illuminate each transparent digit sample
6

(a) Sample phase (b) Center

-π Rad. -π

0

1

(d) Off-axis

(c) All

0

1

0

1

(e) Random

0

1

(f) DPC

-1

1

(g) Optimized

-1

1
1
Brightness (AU)

(h) Optimized LEDs
low noise

(0,0)

LED x
LED y

(i) Optimized LEDs
high noise

-1

Figure 4: Simulation results. (a) Example phase maps of transparent samples (scale bar: 10 µm).
(b)-(g) Associated images under the different forms of LED illumination sketched in Fig. 3(d). Images
in (b)-(d) are from one image capture, while images in (e)-(g) are from two image captures followed
by a subtraction to allow for LED negative weights. (h)-(i) Example optimized LED pattern weights
for the 5 × 5 LED array used to generate optimized images as in (g).
with the 5 × 5 LED array placed 50 mm beneath the sample for uniform angular illumination at 0,
7.2 and 14.5 degrees (on-axis, 1st off-axis and 2nd off-axis LEDs, respectively). The image detector
contains N 2 = 28 × 28 pixels that are each 7 µm in width and exhibits 1% Gaussian readout noise.
The height profile of two example transparent digits and their resulting images are in Fig. 3(b)-(c).
We split the set of J ×L = 60, 000×25 classified digit images into a training set (50,000×25 images)
and testing set (10,000 × 25 images) and run the 5-layer DP-CNN in Fig. 2(c) (using Tensorflow,
see Appendix A for algorithm details). We add a different amount of random Gaussian noise at
the sample plane with a scaling parameter σ to test the robustness of our physical weights. We
independently train and test the system 5 times for 3 different levels of noise and report the mean
performance in Table 1, where we compare the performance of the full DP-CNN pipeline with several
other illuminate-and-classify strategies sketched in Fig. 3(d). When simulating alternative LED
patterns for sample illumination, we fix w as a constant and do not attempt to learn the illumination
weights (only the post-processing layers are optimized, not the physical layer). When we include the
physical layer in the “optimized" case, DP-CNN training produces an optimized LED pattern that we
then use to illuminate the sample during network testing.
Illuminating with only the center LED produces low-contrast images (spatially coherent bright field
illumination, Fig. 4(b)). Classification using this pattern is thus extremely poor: 36.9% on average.
Turning on an off-axis LED produces an image with phase contrast (Fig. 4(d)) that significantly
boosts classification accuracy to 97.2%. So does illuminating with all of the LEDs simultaneously
(spatially incoherent Kohler-type illumination, Fig. 4(c), 97.3%).
The above three illumination schemes assume that each LED weight is positive. We can also test
strategies where the LED weights are either positive or negative. This can be achieved in practice
by capturing two images - a first with the positively weighted LEDs on, and a second with the
negatively weighted LEDs on - and then digitally subtracting the second image from the first. We
test this two-image strategy in simulation for randomly weighted LEDs (Fig. 4(e), 97.2% average),
a differential phase-contrast (DPC) configuration [25] where the right half of the LED array has
uniformly positive weights and the left half has uniformly negative weights (Fig. 4(f), 97.3% average),
7

and finally our DP-CNN optimization pipeline (Fig. 4(g), 98.2% average). From the example images,
it is clear that the optimal illumination strategy produces both a large amount of contrast as well as a
relatively sharp image of each transparent digit, which leads to the highest classification accuracy
across all tested noise levels. Finally, we note that the post-processing layers of our DP-CNN yield
99.3% classification accuracy when trained and tested with an unmodified MNIST image set. So, at
least in this example, phase-only samples are more challenging to classify than absorptive samples
(that is, the relatively unclear images in Fig. 4 are harder to classify than the original MNIST set).
An example collection of DP-CNN optimized “digit classification" LED patterns is in Fig. 4(h)-(i).
The black box at left marks the cutoff between bright field and dark-field LEDs (that is, LEDs at
an angle less than and greater than the lens acceptance angle). Noting positive weights are in red
and negative are in blue, ideal illumination strategies appear to approximately involve subtracting
two brightly-lit images from two different and opposing directions within the bright-field channel,
as is used for DPC imaging. This makes intuitive sense - since the relevant information needed to
classify each digit resides in its phase, the optimal illumination strategy should maximize the amount
of phase contrast within the detected images. However, the opposing bright LEDs do not form a
symmetric pattern, and the optimization process clearly does not converge to a global minimum in
this simulation.

6

Experimental results

Next we test the DP-CNN pipeline in a practical image classification experiment: to automatically
determine if red blood cells are infected with the P. falciparum parasite, a primary cause of malaria.
The infection typically manifests itself as a small spot or ring inside the red blood cell body. Currently,
the leading method for diagnosing P. falciparum infection is manual inspection of stained blood smears
by a clinical expert with an oil immersion microscope [26]. To design a classification microscope
that can automatically and accurately detect infection via our new illumination strategy, we outfit a
standard Olympus microscope with an LED array positioned 40 mm beneath the sample [27, 28]. We
use 29 different LEDs (model SMD 3528, 20 nm spectral bandwidth, 150 µm active area diameter)
that are arranged in 4 concentric rings. We image each sample across a wide field-of-view (FOV)
using a 20X objective lens (0.5 NA, Olympus UPLFLN, 30 degree collection angle) and a large
format CCD detector (Kodak KAI-29050, 5.5 µm pixels). The maximum angle of illumination from
the LED array is approximately 45 degrees (0.7 illumination NA). Under high-angle illumination,
we can thus capture spatial frequencies that are as large as the maximum frequency cutoff of a 1.2
NA oil immersion objective lens [27]. By using a 20X objective lens instead of a high magnification
oil immersion lens, we can image many more cells within its larger FOV but at the expense of a
lower image resolution. We hope to overcome the limited 20X image resolution with our optimized
illumination strategy, which will allow us to simultaneously offer accurate classification and high
detection throughput in an oil-free imaging setup.
Our samples are a number of different slides of single-layer human blood smears. Some of the
red blood cells within each slide are infected with P. falciparum while the majority of cells are not
infected. Of the infected cells, the majority are infected with P. falciparum at ring stage. A minority
of infected cells are trophozoites and schizonts, which help test how well the DP-CNN classifier can
generalize to different stages of infection. Each slide has been lightly stained using a Hema 3 stain.
For each sample, we first capture multiple images by individually illuminating the L = 29 uniquely
positioned LEDs one at a time. We illuminate separately with the red, green and blue channel of each
LED and take 3 separate images to capture color. To create our classification data set, we first identified
cells with non-standard morphology and smoothness (both in bright-field and dark-field images).
Then, we drew small bounding boxes around each cell and used Fourier ptychography (FP) to process
each set of 29 images into an image reconstruction with higher resolution [8]. The FP reconstructions
contain both the cell’s absorption and phase delay at approximately 385 nm resolution (Sparrow
limit), which approximately matches the quality of imaging with an oil-immersion objective lens [27].
Example FP reconstructions are in Fig. 5(g). We then digitally refocused the FP reconstruction to
the best plane of focus and visually inspected each cell to determine whether it was uninfected or
contained features indicative of P. falciparum infection. After each diagnosis, we then cropped the
cell with an approximate 28 × 28 pixel bounding box from each of the 29 raw images. We used
cubic resizing to form 28 × 28 pixel images when necessary to make all cropped images the same
8

(a) Center

(c) Off-axis (d) Random

(e) DPC (f) Optimized (g) FP (29 im.)

Uninfected

Infected

(b) All

0

1

0

1

0

1

0

1

-1

1

-1

0.7

0

1

Figure 5: Experimental results of P. falciparum-infected cells (top 3 rows) and uninfected cells
(bottom 3 rows) using different LED illumination patterns (scale bar: 2 µm). (a)-(c) Images from
one image capture. (d)-(f) Images from two captures and a subtraction. (g) FP reconstructions
formed after capturing and processing 29 unique images (magnitude of reconstruction shown). With
the optimized LED pattern in (f), areas of infection appear as bright spots that are missing from
uninfected cells.

size. Each 28 × 28 × 29 data cube and its binary diagnosis label (infected or uninfected) form one
example within our initial dataset.
We diagnosed and extracted a total of 1258 data cubes from cells across 8 different microscope slides
(563 uninfected, 695 infected). We then randomly shuffled these examples and separated them into
training and testing sets. To increase algorithm robustness, we applied data augmentation (factor of
24) separately to the training and testing sets. Each final training set contained 25,000 examples and
each final test set contained 5,000 examples (with 50% uninfected and 50% infected cells). 4 different
transformations were used for data augmentation: image rotation (90 degree increments), image
blurring (3 × 3 pixel Gaussian blur kernel), elastic image deformation [29], and the addition of a small
amount of Gaussian noise. These transformations align with the following experimental uncertainties
that we expect in future experiments: arbitrary slide placement, slight microscope defocus, distortions
caused by different smear procedures and varying amounts of sensor readout noise.
Similar to our simulation, we compare the performance of our DP-CNN’s joint illumination optimization/classification process with several alternative illuminate-and-classify strategies. Average
accuracies (each over 7 independent trials) and their standard deviations (STD) are presented in
Table 2. Due to our light staining of each slide, direct illumination using just the center LED often
produces an observable indication of cell infection, as shown in Fig. 5(a), top. However, accurate
diagnosis at the resolution of a 20X microscope objective lens here remains challenging. As noted
above, an oil-immersion objective lens is typically required for this task [26]. Thus, it is not surprising
that the classification accuracy here remains relatively low: approximately 90%. Using incoherent
illumination (all of the LEDs illuminate the sample simultaneously, Fig. 5(b)) increases the image
resolution [24] but significantly decreases image contrast. It appears that maintaining high contrast is
extremely important for accurate classification of infection, as the classification accuracy drops to
9

Table 2: Experimental results, DP-CNN classification of cells with P. falciparum infection
Illumination Type & Classification Score
Algo. (step)

Value

Center

All

Off-axis

Random

DPC

Optim.

FP

Adam (10−4 )

Average
Majority
STD

0.896
0.902
0.012

0.746
0.757
0.012

0.832
0.838
0.010

0.813
0.893
0.037

0.859
0.875
0.006

0.932
0.957
0.019

0.951
0.989
0.011

Adam (10−3 )

Average
Majority
STD

0.906
0.920
0.011

0.689
0.700
0.025

0.863
0.886
0.017

0.806
0.885
0.080

0.848
0.881
0.008

0.949
0.983
0.020

0.968
0.987
0.008

∼72% with incoherent light. Off-axis illumination (Fig. 5(c)) generates higher image contrast and
improves accuracy to 85%, not quite to the level of center LED illumination.
We also consider procedures that capture and subtract two images. Randomly selecting positive
and negative illumination weights produces low contrast (Fig. 5(d)) and classification remains poor
(80%). Differential phase-contrast imaging using opposing illumination from 2 LEDs and an image
subtraction does slightly better (Fig. 5(e), 85%). The accuracy of our DP-CNN optimized illumination
pattern, at approximately 94%, remains significantly higher than all alternatives (Fig. 5(f)). In Table
2, we also present classification accuracies for each strategy based on a ensemble method over 7
independent trials (a majority vote [30, 31], ’Majority’ column). Here, we define a cell as (un)infected
if it is classified as (un)infected in 4 or more of the 7 independent trials. This effectively combines
the 7 classifiers to increase accuracy by 2.8% on average, and leads to approximately 98% accuracy
for our optimized LED illumination scheme. The false negative rate from the DP-CNN tests were on
average approximately 16% higher than the false positive rate (42% of errors were false-positives),
which may be partially accounted for by the unequal number of infected and uninfected cell images
in our training data. Reducing this false negative rate will be a major focus of future work.
Several DP-CNN optimized LED patterns are shown in Fig. 6. Unlike the simulation, each independent trial of DP-CNN with the experimental data converges to a similar optimal weight pattern,
up to an arbitrary sign offset. That is, approximately 50% of the optimized patterns show positive
intensity weights along the outer ring and mostly negative weights within, which we can flip to
match the other 50% by multiplying all weights by -1. After accounting for this sign offset we show
the average optimized LED pattern and its variance over 14 independent trials in Fig. 6(b)-(c). 5
example patterns from the 14 independent train/test trials are in Fig. 6(d). Most of the weight energy
within the average pattern (75.4%) is dedicated to the outer ring of 12 LEDs, suggesting that high
spatial frequency information is important to accurately classify infection. This ring-like structure
conceptually matches the condenser annulus design used in phase contrast microscopes, but here the
ring is not uniformly weighted. Furthermore, 85.4% of the average LED weight energy is negative.
As less light makes it through the lens at high illumination angles, the resulting optimized images
are thus noisier (see Fig. 5(f)). Although the classifier must compete with increased image noise,
the mixture of positive LED weights from the center and negative LED weights from the outer ring
visually highlight the inner-cell infections as bright spots in Fig. 5(f), apparently allowing the digital
classifier to achieve its higher accuracy versus the alternative illumination schemes.
Finally, we compare the performance of DP-CNN (using 2 images) to two alternative classification
methods that we expect to exhibit higher accuracy. First, we attempt to classify malaria parasite
infection from the high-resolution Fourier ptychographic reconstructions of each cell. For each data
cube, we use the FP algorithm [8] to process all 29 individual images to form a high-resolution
complex-valued reconstruction (56 × 56 pixels, 385 nm Sparrow limit, Fig. 5(g)). We apply data
augmentation (same parameters) to the magnitudes of FP reconstructions to create a training/testing
set with 25K/5K high-resolution labeled examples. We then process this set with the DP-CNN
post-processing layers and obtain a slightly higher classification accuracy than our 2-image DP-CNN:
96% on average and 99% majority vote. This slight improvement is not surprising, given that FP
requires a 15X increase in the amount of data that must be recorded per cell.
Second, we obtained a baseline classification accuracy from a trained human expert who was not
involved in the sample preparation or imaging experiments. After randomly selecting 50 labeled
cells from our full dataset (0.5 probability uninfected, 0.5 infected), we displayed 4 images of each
10

(a) LED array layout

(b) Optimized weight average

-1.3

1.3

(c) Optimized weight variance

0

0.25

(d) Example optimized LED patterns
1.5
Weight (AU)

-1.5

Figure 6: DP-CNN optimized LED illumination patterns. (a) Location of 29 LEDs with bright/dark
field boarder marked as dashed line. (b) Average LED weights and (c) variance for the illumination
unit computed from 14 independent trials. (d) 5 example optimized LED patterns.
The above is for 14X with no random images, Adam 1e-3 and Adam 1e-4

cell to the expert: a low-resolution image from the center LED, from the bright-field off-axis LED,
from the dark-field off-axis LED, and the FP-reconstructed magnitude. Based on these 4 images, the
expert made a diagnosis that matched the assigned label with an accuracy of 96% (48 matched, 2
mismatched, both mismatches false positives). Diagnosis errors can be partially attributed to the low
resolution of each raw image and artifacts present in the FP reconstruction.

7

Discussion and future work

In summary, we have presented a framework to jointly optimize the physical parameters of a
microscope and the CNN weights used to classify the images that it generates. As a demonstration,
we improved the accuracy of malaria classification by determining an optimal LED-based microscope
illumination pattern. Our experiment shows that the physical parameters of a microscope are important
to a particular image classification task. This should not necessarily come as a surprise, given that an
optimized microscope design can capture more relevant information than a standard system (e.g., by
introducing phase contrast and emphasizing important spatial frequencies).
In a number of respects, our experiments were very much a proof-of-concept and much future work
is needed for a more robust malaria detection process. First, we must increase the size of our training
sets with more annotated samples from a large number of patients. Second, we will involve several
trained professionals to label these datasets of stained and unstained P. falciparum-infected cells at
different stages of infection. To make the test as secure and reliable as possible, a major focus will be
on the elimination of the false determinations, in particular the false negatives. We will also use a
sorting technique (as in Ref. [19]) to first separate infected from uninfected cells before imaging to
obtain a better ground-truth classification. Finally, we need to compare the performance of our CNN
pipeline with prior methods for malaria classification that use standard microscope images [21, 22].
A combination of our physical optimization process with these alternative learning pipelines may
yield a higher overall classification accuracy. In general, we anticipate that this technology may be
directly extended to diagnosis P. falciparum infection at a per patient level (as opposed to a per-cell
level). Given the larger number of infected cells per smear, we expect much higher patient-specific
classification accuracies as opposed to the per-cell classification accuracies reported here.
Outside of the particular goal of classifying malaria infection, we see a number of potential extensions
of our new framework. First, our optimized LED patterns require two images (assuming positive
and negative weights). Following recent work with spectral classification [32], a future strategy may
use an adaptive approach to classify with more than two uniquely lit images (e.g., the LED pattern
for each subsequent image can depend on the classification scores for previous images). Second,
11

there are a large number of alternative physical aspects of a microscope (or an imaging system in
general) to potentially optimize via a CNN. An immediate extension could jointly optimize both the
illumination and a phase plate (aperture mask) to place in the microscope back focal plane, which
effectively customizes the condenser annulus and phase ring in phase contrast setups for a particular
CNN-based goal. Other microscope design options include (but are not limited to) optimizing spectral
and polarimetric degrees of freedom, improving axial resolution and depth detection, addressing
various sensor characteristics, and enhancing abilities to see through scattering material like tissue.
Many of these aspects may find their way into the physical layers of our P-CNN model. In general,
we are hopeful that the initial foundation presented here will help others explore more connections
between artificial neural networks and the physical devices used to acquire their data.
Acknowledgments
We thank Xiaoze Ou, Jaebum Chung and Prof. Changhuei Yang for capturing and sharing the
raw images used in the experiment and thank the lab of Prof. Ana Rodriguez for providing the
malaria-infected cells. R.H. acknowledges funding from the Einstein Foundation Berlin.

Appendix A: Algorithm details
All results were obtained using Tensorflow. For both the simulations and experiments, we used the
cross-entropy error metric and also applied dropout before the final readout layer. For our simulation
results, we trained with 50,000 iterations and a batch size of 50 and used the Adam method for
stochastic optimization [33] with a step size of 10−4 . For the experimental results, we trained with
25,000 iterations using a batch size of 50 and report results using Adam Optimization with a step
size of 10−3 and 10−4 . For the Adam optimizer we set β1 = 0.9, β2 = 0.999 and  =1e-8. Here is a
brief review of the experimental DP-CNN pipeline in Fig. 2(c): layer 1 (physical layer) is a tensor
product between a 28 × 28 × 29 input and a 1 × 29 weight vector w, layer 2 uses a 5 × 5 convolution
kernel, 32 features, ReLU activation and 2 × 2 max pooling, layer 3 uses a 5 × 5 convolution kernel,
64 features, ReLU activation and 2 × 2 max pooling, layer 4 is a densely connected layer with 1024
neurons and ReLU activation and layer 5 is densely connected readout layer. We apply dropout with
a probability of 0.5 between layers 4 and 5.

References
[1] A. Esteva et al., "Dermatologist-level classification of skin cancer with deep neural networks,"
Nature 542, 115–118 (2017).
[2] O. Ronneberger, P. Fischer, and T. Brox, "U-net: Convolutional networks for biomedical image
segmentation," in Proc. MICCAI, 234–241, Springer (2015).
[3] A. van den Oord, N. Kalchbrenner and K. Kavukcuoglu, "Pixel Recurrent Neural Networks,"
arXiv:1601.06759 (2016).
[4] Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner, "Gradient-based learning applied to document
recognition," Proc. IEEE 86, 2278-2324 (1998).
[5] V. Ljosa, K. L. Sokolnicki and A. E. Carpenter, "Annotated high-throughput microscopy image
sets for validation," Nature Methods 9, 637 (2012).
[6] M. G. Gustafsson, "Surpassing the lateral resolution limit by a factor of two using structured
illumination microscopy," J. Microsc. 198, 82–87 (2000).
[7] E. Betzig et al., "Imaging Intracellular Fluorescent Proteins at Nanometer Resolution," Science
313, 1642–1645 (2006).
[8] G. Zheng, R. Horstmeyer and C. Yang, "Wide-field, high-resolution Fourier ptychographic
microscopy," Nature Photonics 7, 739–745 (2013).
[9] Y. LeCun, Y. Bengio and G. Hinton, "Deep Learning," Nature 521, 436–444 (2015).
[10] G. Litgens et al., "A survey on deep learning in medical image analysis," arXiv:1702.05747
(2017).
[11] J. Macdonald, A. J. Breese and N. L. Hanbury, "Optimization of a Lens Design Using a Neural
Network," in Proc. SPIE 1965, Applications of Artificial Neural Networks IV, 431 (1993).
12

[12] A. Chakrabarti, "Learning Sensor Multiplexing Design through Back-propagation," in Adv.
Neural Inf. Proc. Sys. (NIPS) 2016, 3081–3089 (2016).
[13] S. Diamond, V. Sitzmann, S. Boyd, G. Wetzstein and F. Heide, "Dirty pixels: Optimizing image
classification architectures for raw sensor data," arXiv:1701.06487 (2017).
[14] R. Horisaki, R. Takagi and J. Tanida, "Learning-based imaging through scattering media," Opt.
Express 24, 13738–13743 (2016).
[15] G. Satat, M. Tancik, O. Gupta, B. Heshmat and R. Raskar, "Object classification through
scattering media with deep learning on time resolved measurement," Opt. Express 25, 17466–
17479 (2017).
[16] H. G. Chen et al., "ASP Vision: Optically Computing the First Layer of Convolutional Neural
Networks using Angle Sensitive Pixels," arXiv:1605.03621 (2016).
[17] T. C. Wang, J. Y Zhu, N. K. Kalantari, A. A. Efros and R. Ramamoorthi, "Light field video
capture using a learning-based hybrid imaging system", ACM Transactions on Graphics (TOG)
36, 133 (2017).
[18] K. Kulkarni, S. Lohit, P. Turaga, R. Kerviche and A. Ashok, “ReconNet: Non-Iterative Reconstruction of Images from Compressively Sensed Random Measurements," arXiv:1601.06892
(2016).
[19] H. S. Park, M. T. Rinehart, K. A. Walzer, J. A. Chi and A. Wax, "Automated Detection of P.
falciparum Using Machine Learning Algorithms with Quantitative Phase Images of Unstained
Cells," PLoS One 11, e0163045 (2016).
[20] X. Huang et al., "Machine learning based single-frame super-resolution processing for lensless
blood cell counting," Sensors 16, s16111836 (2016).
[21] D. K. Das et al., "Machine learning approach for automated screening of malaria parasite using
light microscopic images," Micron 45, 97–106 (2013).
[22] J.A. Quinn et al., "Deep Convolutional Neural Networks for Microscopy-Based Point of Care
Diagnostics," in Proc. Int. Conf. Machine Learning for Health Care 56, 1–12 (2016).
[23] A. Krizhevsky, I. Sutskever and G. E. Hinton, "ImageNet classification with deep convolutional
neural networks," in Adv. Neural Inf. Proc. Sys. (NIPS) 2012, 1106–1114 (2012).
[24] J. Goodman, Introduction to Fourier Optics (Mcgraw-Hill, 1996).
[25] S. Mehta and C. J. R. Sheppard, "Quantitative phase-gradient imaging at high resolution with
asymmetric illumination-based differential phase contrast," Opt. Letters 34, 1924–1926 (2009).
[26] World Health Organization, Malaria microscopy quality assurance manual, version 1 (World
Health Organization, 2009).
[27] X. Ou, R. Horstmeyer, G. Zheng, C. Yang, "High numerical aperture Fourier ptychography:
principle, implementation and characterization," Opt. Express 23, 3472–3491 (2015).
[28] R. Horstmeyer, R. Y. Chen, X. Ou, B. Ames, J. A. Tropp and C. Yang, "Solving ptychography
with a convex relaxation," New. J. Phys. 17, 053044 (2015).
[29] P. Y. Simard, D. Steinkraus and J. C. Platt, "Best practices for convolutional neural networks
applied to visual document analysis," in Proc. ICDAR 7(2), 958–962 (2003).
[30] S. Lee, S. Purushwalkam, M. Cogswell, D. Crandall, and D. Batra, "Why M heads are better
than one: Training a diverse ensemble of deep networks," arXiv:1511.06314 (2015).
[31] B. Lakshminarayanan, A. Pritzel and C. Blundell, "Simple and scalable predictive uncertainty
estimation using deep ensembles", arXiv:1612.01474 (2016).
[32] M. Dunlop-Gray et al., "Experimental demonstration of an adaptive architecture for direct
spectral imaging classification," Opt. Express 24, 18307–18321 (2016).
[33] D. P. Kingma and J. Ba, "Adam: A Method for Stochastic Optimization," arXiv:1412.6980v9
(2014).

13

