Chromatic aberration correction - Computing Science

Transcription

Chromatic aberration correction - Computing Science
Skin Research and Technology 2011; 17: 339–347
Printed in Singapore All rights reserved
doi: 10.1111/j.1600-0846.2011.00504.x
r 2011 John Wiley & Sons A/S
Skin Research and Technology
Chromatic aberration correction: an enhancement to the
calibration of low-cost digital dermoscopes
Paul Wighton1,2,3, Tim K. Lee1,2,3, Harvey Lui2,3, David McLean3 and M. Stella Atkins1
1
School of Computing Science, Simon Fraser University, Burnaby, BC, Canada, 2Cancer Control Research and Cancer Imaging, BC Cancer Agency,
Vancouver, BC, Canada and 3Department of Dermatology and Skin Science, Photomedicine Institute, University of British Columbia and Vancouver
Coastal Health Research Institute, Vancouver, BC, Canada
Background/purpose: We present a method for calibrating
low-cost digital dermoscopes that corrects for color and
inconsistent lighting and also corrects for chromatic aberration. Chromatic aberration is a form of radial distortion that
often occurs in inexpensive digital dermoscopes and creates red and blue halo-like effects on edges. Being radial in
nature, distortions due to chromatic aberration are not
constant across the image, but rather vary in both magnitude and direction. As a result, distortions are not only
visually distracting but could also mislead automated characterization techniques.
Methods: Two low-cost dermoscopes, based on different
consumer-grade cameras, were tested. Color is corrected
by imaging a reference and applying singular value decomposition to determine the transformation required to ensure
accurate color reproduction. Lighting is corrected by ima-
E PRESENT a
method to calibrate inexpensive
digital dermoscopes, made by attaching a
traditional dermoscope to a consumer-grade digital camera. Such ‘low-cost’ digital dermoscopes
are becoming increasingly popular as the prevalence of dermoscopic use in the clinic increases,
and the cost of digital cameras decreases. It is
hoped that such systems will lead to increased
patient care through the use of teledermatology
(1) or automated diagnostic methods (2) as
well as enable the generation of a large database
of various skin conditions to facilitate future
research.
The nature of such digital dermoscopes poses
several challenges. Firstly, the illumination across
the field of view is not consistent, resulting in
separate areas of over- and under-exposure
within the same image. Secondly, the color of
the image acquired is not accurate. Commercial
digital cameras are optimized to operate under
certain typical lighting conditions (such as sunlight, incandescent light, etc.), and thus have
W
ging a uniform surface and creating lighting correction
maps. Chromatic aberration is corrected using a secondorder radial distortion model.
Results: Our results for color and lighting calibration are
consistent with previously published results, while distortions due to chromatic aberration can be reduced by 42–
47% in the two systems considered.
Conclusion: The disadvantages of inexpensive dermoscopy can be quickly substantially mitigated with a suitable
calibration procedure.
Key words: digital dermoscopy – calibration – chromatic
aberration – color and lighting correction
& 2011 John Wiley & Sons A/S
Accepted for publication 10 December 2010
difficulty estimating the properties of unconventional light sources such as those within dermoscopes. Moreover, consumer-grade cameras
are more concerned with presenting visually
esthetic images, rather than a faithful rendition
of color per se.
These issues have been identified in the past,
and calibration methods to render accurate color
and to correct inconsistent and lighting have been
proposed (3–6). These methods acquire images of
reference colors, which are used to derive transformations for accurate color reproduction as
well as ‘intensity maps’ to correct for variations
in lighting intensity.
In this paper, in addition to calibrating for color
and lighting, we examine a distortion effect
known as chromatic aberration, and correct for
it accordingly. Chromatic aberration occurs when
the refractive index of the optics is not constant
with respect to wavelength. This effect is illustrated in Fig. 1. As the refractive index of the
lens varies slightly with wavelength, the color of
339
Wighton et al.
Fig. 1. Chromatic aberration (a) occurs when the refractive index of light varies with respect to wavelength. Relative to the green channel, this results
in a (b) ‘barrel’ distortion of the red channel and a (c) ‘pincushion’ distortion of the blue. These distortions cause edges to appear in slightly different
locations in each color channel, resulting in (d) blue and red ‘halo’ effects. Plotting the pixel intensities across a section of the square (e), it is evident
that the location of the edges varies with respect to the color channel.
the light will affect the location of the focal plane.
If the camera is set such that the green light is in
focus, the red light will resolve slightly behind
the focal plane while the blue light will resolve
slightly in front. The result, relative to the green
channel, is a ‘barrel’ distortion of the red channel
and a ‘pincushion’ distortion of the blue channel.
Expensive digital skin imaging systems can correct this optically; however, digital dermoscopy
seems to be trending toward mating an already
available dermoscope with an inexpensive digital
340
camera in the name of cost and convenience.
While distortions due to chromatic aberration
can be partially alleviated by decreasing the
camera aperture size (thereby restricting the use
of the lens to the center, where the distortion
effects are minimized), such distortions are still
evident when using inexpensive components.
Being radial in nature, distortions due to chromatic aberration are not constant across the image, but rather vary in both magnitude and
direction. Such distortions are visually distracting
Chromatic aberration correction
and possibly clinically confounding. Furthermore, these distortions could also mislead automated characterization techniques (such as the
automated identification of occluding hair or
dermoscopic structures). For example, the variance of color within a lesion is an extremely
important feature in both clinical as well as
automated diagnosis (2), the accuracy of which
would certainly be curbed by the introduction of
spurious shades of red and blue. As a result, a
software-based method of chromatic aberration
correction is becoming increasingly necessary. We
present a calibration method that not only corrects for inconsistent lighting and ensures accurate color reproduction but also corrects for
chromatic aberration.
Methods
The imaging systems
We use two digital dermoscope systems in order
to design and validate our calibration method.
The first is a Dermlite II Pro (3Gen LLC, San Juan
Capistrano, CA, USA) attached to a Canon
Powershot G9 (Canon Inc., Tokyo, Japan) digital
camera using a custom lens adapter (Lensmate,
Gig Harbor, WA, USA) and standard stepping
rings. A custom light shroud was machined and
attached to the end of the dermoscope so that no
ambient lighting would be present in the images.
Images are acquired in the ‘raw’ mode with a
resolution of 4000 3000 pixels. The spatial resolution is approximately 0.0073 mm2. The second system is a Dermlite II Pro attached to a Sony
Cybershot DSC-W300 (Sony Corporation, Tokyo,
Japan) using a custom lens adapter. The Sony
camera acquires jpeg images with a resolution of
4224 3168 pixels and an approximate spatial
resolution of 0.0063 mm2. We refer to these systems as the ‘Canon system’ and the ‘Sony system,’ respectively. As the magnitude of chromatic
aberration is related to the aperture size of the
camera, both cameras were set to use the smallest
possible aperture size. The Canon camera parameters were set to: iso 100, shutter 1/30, f/5.0
and the Sony camera parameters were set to: iso
100, shutter 1/40, f/5.6.
A 24-patch color chart (X-Rite, Grand Rapids,
MI, USA) and a black and white checkered
pattern are used to calibrate the system. The
freely available, open-source tool dcraw (7) is
used to process the raw sensor data and convert
it to uncalibrated CIE XYZ colorspace (8). An
S2000 spectrometer (Ocean Optics, Dunedin, FL,
USA) was used to measure the reflectance curve
of each color patch of the color chart, which acts
as the ground truth color measurement.
A note on colorspaces
Three colorspaces are used throughout this paper. The first is CIE XYZ, which, when properly
calibrated, is linear with respect to the sensitivities of the retinal cone cells in a standard human
observer. When uncalibrated (as is when dcraw is
used to convert from ‘raw’ format), it is linear
with respect to the sensitivities of the camera’s
CCD. Both color and lighting corrections are
performed in this space. The second colorspace
used is sRGB, which is a standardized colorspace
used for display under typical viewing conditions. It is non-linear with respect to CIE XYZ
because of the inclusion of a ‘gamma correction’
step, which compensates for the non-linearities of
display devices. Because gamma correction is
implicit in sRGB, we do not perform an explicit
gamma correction step as in (4). Chromatic
aberration is performed in this space and all
images throughout this paper are presented in
sRGB. The third colorspace used is CIE L a b ,
which is an approximately perceptually uniform
colorspace, but non-linear with respect to
both XYZ and sRGB. This colorspace is used to
compare our method with previous results (3).
Conversions between these three colorspaces are
well defined (8).
Color calibration
Given a color c 5 [x y z]T in the camera’s uncalibrated CIE XYZ colorspace, we transform it into
the calibrated colorspace c ¼ ½x y z T via a 3 3
color transformation matrix, M:
c ¼ Mc
To compute M, we measure each of the 24
patches of the color chart using the dermoscope
as well as the spectrometer. An image of each
color patch is acquired using the dermoscope and
is converted to an uncalibrated CIE XYZ space.
The color of each patch is calculated by averaging
over a small area in the center of the image where
the lighting is the strongest. These uncalibrated
color values are stored in a 24 3 matrix C. Next,
the spectral reflectance curves of each of the 24
color patches are measured using a spectrometer.
These reflectance curves are then multiplied
by the three CIE standard observer matching
341
Wighton et al.
functions (8), which approximate the absorption
spectra of the short, medium and long cones of the
human retina, respectively. The resulting spectra
are then integrated, yielding a point in the CIE
XYZ space. These calibrated color values are
stored in a 24 3 matrix C : It then follows that
C ¼ MC
and the least squares solution for M is obtained via
singular value decomposition
M ¼ ðCT CÞ1 CT C
Once the transformation matrix M is computed,
acquired images are transformed to the CIE XYZ
space by multiplying uncalibrated color values by
M. An example of this is shown in Fig. 2.
Lighting calibration
After calibrating for color, the colors in the center
of the images are now much more accurate;
however, the intensity of the lighting is not
consistent across the image and must therefore be accounted for. We correct for this inconsistency by creating an illumination correction
map (4).
To create this map, we consider the white patch
on the color chart. Gaussian blurring is applied to
the acquired image of this patch to remove any
high-frequency variations (such as imperfections
in the surface, dust, etc.) and the result for each
channel is stored in the matrix XW, YW and ZW,
respectively. We then relate these acquired values
to the ground truth values obtained using the
spectrometer data (XS, YS, ZS). The correction
map for the X channel (XC) is then computed as
follows:
XS
XC ¼
XW
YC and ZC are similarly computed. Newly
acquired images are then corrected by pairwise
multiplication with this correction map.
Chromatic aberration calibration
As mentioned above, chromatic aberration manifests itself as a ‘barrel’ distortion of the red
channel and a ‘pincushion’ distortion of the
blue channel, relative to the green channel. We
emphasize that the distortion due to chromatic
aberration is relative to the green channel. There
is also an overall distortion effect across all
channels; however, this is negligible when compared with the elasticity of skin. The effect of
chromatic aberration can be seen in Fig. 3. Figure
342
Fig. 2. Dermoscopic image of a melanoma in situ acquired with the
Canon system as processed by (a) Canon’s ZOOMBROWSER EX software
(b) our color calibration procedure.
3b shows a magnified view of the upper left area,
where the edge of the checkered pattern has a
bluish tint along the upper and left edges and a
reddish tint on the right and lower edges. This
tinting is reversed in Fig. 3c, where the magnified
view has a different location relative to the center
of the lens.
Chromatic aberration is a form of radial
distortion and thus has the following properties: (1) It is symmetric with respect to the
center of the lens, (2) the magnitude of the
distortion is a function of the distance to the
center of the lens and (3) the direction of
Chromatic aberration correction
Fig. 3. Correcting for chromatic aberration. (a) The checkered pattern imaged with the dermoscope. The center of the lens can be found using lines that
characterize the direction of distortion. (b) Magnified view of the upper left area; note the blue tint along the top and left edges of the squares and the
red tint along the bottom/right. The centroids of each square in each channel are denoted by red, green and blue circles, respectively (distances between
centroids have been exaggerated for illustrative purposes). These centroids are used to generate the yellow lines. (c) Magnified view of the lower right
area; here the tinting is reversed due to the location of the squares with respect to the center of the lens. (d) Finding the center of the lens in image
coordinates via least squares using many lines.
the distortion for any given point is radial,
that is, along the line joining it to the center of
the lens. We can therefore correct chromatic
aberration by using a radial distortion model (9)
once we have determined (1) the center of the
lens in image coordinates and (2) the relationship
between the magnitude of the distortion and the
distance to the lens center. Both tasks can be
accomplished by imaging a black and white
checkered pattern.
Determining the center of the lens
The center of the lens is determined by examining
the direction of the distortion in each square of
the checkered pattern. The direction of the
distortion in each square is characterized by a
line. As the distortion is radial in nature, this
line must also pass through the center of lens.
We begin by computing the centroid of each
square to sub-pixel accuracy in the red, green
and blue channels, respectively (as in Fig. 3b
and c). These three points are used to define a
line in the form ax1by1c 5 0. The center of
the lens can be determined using two such lines
(as in Fig. 3a); however, greater accuracy is
achieved using the least squared solution to the
intersection of multiple lines (as in Fig. 3d). Let
(ai, bi, ci); i 5 1, . . ., N represent the coefficients of
the ith line computed from the ith square. The
center of the lens (xc, yc) is the point that minimizes the sum squared distance to the lines as
follows:
ðxc ; yc Þ ¼ argminx;y
N
X
di ðx; yÞ2
i¼1
where di(x, y) is the perpendicular distance from
the point (x, y) to the ith line (ai, bi, ci):
di ðx; yÞ ¼
jai x þ bi y þ cj
qffiffiffiffiffiffiffiffiffiffiffiffiffiffi
a2i þ b2i
343
Wighton et al.
Fig. 4. Characterizing the distortion due to chromatic aberration with respect to the distance from the center of the lens in the red and blue channels.
Each point represents the distortion at the center of a square of the checkered image while the lines represent the estimated distortion models of the
system.
for which the closed-form solution is derived:
PN
PN 2 PN
PN
i¼1 bi ci
i¼1 ai i¼1 ai ci
i¼1 ai bi
yc ¼
P
2 P
P
N
N
N
2
2
i¼1 ai bi i¼1 bi
i¼1 ai
xc ¼
yc
PN
PN
i¼1 ai bi PN 2
i¼1 ai
i¼1 ai ci
Determining the magnitude of the distortion
After determining the center of the lens, we use a
second-order radial distortion model (8) to estimate the distortion of the red and blue channels.
We seek to determine the function D(r) that
represents the distortion (measured in pixels)
with respect to the distance from the lens center
(also measured in pixels). We determine these
distortion functions for the red [DR(r)] and blue
[DB(r)] channels independently.
Red channel distortion DR(r) is sampled at each
square of the checkered pattern by taking the
distance between the red and the green centroids.
The distance from the lens center (r) is measured
with respect to the green centroid. Distortion in
the blue channel is similarly obtained. After
sampling these distortion functions at each
square, the functions are modelled as secondorder polynomials (illustrated in Fig. 4) to create
a distortion map. The resulting polynomials are
used to warp the red and blue channels to align
344
them with the green channel. The warping is
performed as follows: for each pixel in the red
and blue channels, a displacement vector is calculated. The magnitude of the vector is determined
by D(r) while the direction is set to be radial.
Results
We evaluate the effectiveness of our calibration
procedure using our primary skin lesion imaging
system (the ‘Canon system’) as well as a secondary system (the ‘Sony system’). The Sony camera
is unable to acquire images in the ‘raw’ mode and
therefore a method to perform white balancing
must be specified. Custom white balancing was
used so that the resulting transformation would
be constant across images. The white patch of the
color chart was used as reference white.
Color/lighting
To evaluate the effectiveness of color calibration,
we follow the lead in (3) and report precision and
accuracy values. Precision is the degree to which
repeated measurements are reproducible, while
accuracy is the degree to which measurements
match those of a reference system (in this case, a
spectrometer). Both are measured as DE, which
represents Euclidian distances in the L a b space,
as DE 5 1 corresponds (approximately) to a just
noticeable perceptual difference. As in (3), we
Chromatic aberration correction
TABLE 1. Precision and accuracy measurements for both imaging systems
compared to previous work
Precision
Canon system
Sony system
Vander Haeghen et al. (3)
Accuracy
Mean
Maximum
Mean
Maximum
6.4
10.0
6.2
14.8
23.6
13.3
0.43
10.2
0.30
1.2
22.4
1.2
report the mean and maximum values. Table 1
summarizes the results.
Chromatic aberration
To analyze the effect of chromatic aberration
correction, we consider the joint distribution of
the pixels’ red and blue intensity values in the
checkered image. Under ideal conditions, we
would expect to see only two types of pixels:
black and white. If we were to plot such a joint
distribution, we would expect to see two distinct
regions: the first at the bottom left representing
the black pixels and the second at the upper right
representing the white pixels. However, due to
the limitations in the resolution of the camera (as
well as in the chequered pattern itself), we observe many partial volume effects along the
black/white borders, resulting in the inclusion
of various shades of gray pixels. Consequently,
we would expect such a joint distribution to
include a region along the line joining the ideal
black and white pixels. Chromatic aberration
further distorts this distribution by conferring red and blue hues to these gray edge
pixels, creating a ‘bulge’ in our idealized line
distribution.
We can therefore visually evaluate the effect of
chromatic aberration correction by examining
these joint distributions. Figure 5 shows such
distributions before and after correcting for chromatic aberration in the Canon system. The effect
can also be quantified by taking the moment of
inertia of the distribution about the idealized line
distribution. This is equivalent to measuring the
sum squared distance of the pixels from the
idealized line (where distance is Euclidian rather
than the vertical). For a frequency distribution
F(r, b), the moment is calculated as follows:
I¼
255 X
255
X
Fðr; bÞðr bÞ2
r¼0
0
2
Fig. 5. Log-frequency plots of the joint distribution of pixel intensities
(red channel vs. the blue channel) for the checkered image as imaged by
the Canon system (a) before correcting for chromatic aberration and (b)
after. As the checkered image is grayscale, all the pixels would fall on
the diagonal line under an ideal imaging system. The log of the
frequencies was plotted for visualization purposes.
For the Canon system, the moment before and
after correction is 562.8 and 296.9, respectively,
resulting in an improvement of 47.2%. For the
Sony system, the moments are 442.8 and 258.1,
respectively, resulting in an improvement of
41.7%. The effect of chromatic aberration correction on the checkered pattern in the Canon
system is shown in Fig. 6.
Discussion
As can be seen in Table 1, the accuracy and
precision values for the Canon system closely
match those of the previous work, while the Sony
system fairs considerably worse. It is believed
that this difference can be attributed to the
inability to access the raw sensor data on the
Sony camera. There are many proprietary trans-
345
Wighton et al.
Fig. 6. The effects of chromatic aberration correction on the checkered pattern as imaged by the Canon system (a, b), before chromatic aberration
correction and (c, d) after chromatic aberration correction. Notice the reduction in the red and blue halos as well as the alignment of the edges in the
intensity plots.
formations that consumer cameras perform on
raw sensor data in the name of esthetics when
converting to a standard image format such as tiff
or jpeg. If these transformations are constant across
images, then under certain conditions, it is possible
that calibration can undo them. If, however, these
transformations are not constant across images
(e.g. contrast normalization), then it is impossible
for a calibration method to correct for this. It is
suspected that the relatively poor precision and
accuracy observed in the Sony system is due to
such transformations. This gives strong motivation
for ensuring that a camera has raw mode capabilities if it is to be used in a setting where accurate
color reproduction is important.
Chromatic aberration is an interesting phenomenon that has hitherto gone unstudied in
References
1. Perednia DA, Brown NA. Teledermatology: one application of telemedicine. Bull Med Libr Assoc
1995; 83: 42–47.
2. Day GR, Barbour RH. Automated
melanoma diagnosis: where are
346
digital dermoscopy. While expensive optical systems are designed to mitigate chromatic
aberration optically, the growing tendency to
create low-cost ad hoc digital dermoscopes
suggests that this will only become more
of a concern in the future. As chromatic
aberration can be partially managed via camera
settings, we recommend always using the
minimum aperture size with any digital
dermoscope that uses a consumer-grade camera.
Additionally, we show that chromatic aberration
can be further mitigated via software-based
calibration.
Furthermore, it may be possible to exploit
chromatic aberration for beneficial ends, such as
improving the automatic detection of hair in
dermoscopic images (10).
we at? Skin Res Technol 2000; 6:
1–5.
3. Vander Haeghen Y, Naeyaert JM,
Lemahieu I, Philips W. An imaging
system with calibrated color image
acquisition for use in dermatology.
IEEE Trans Med Imaging 2000; 19:
722–730.
4. Grana C, Pellacani G, Seidenari S.
Practical color calibration for dermoscopy, applied to a digital epiluminescence microscope. Skin Res
Technol 2005; 11: 242–247.
5. Maglogiannis I. Design and implementation of a calibrated store and
forward imaging system for teleder-
Chromatic aberration correction
matology. J Med Syst 2004; 28: 455–
467.
6. Spaces C. Consistent cutaneous
imaging with commercial digital
cameras. Arch Dermatol 2006; 142:
42–46.
7. Coffin D. Dcraw software. 2008. Available at http://www.cybercom.net/
dcoffin/dcraw/ (accessed March
23, 2010).
8. Ebner M. Color constancy. New
York: Wiley, 2007.
9. Devernay F, Faugeras O. Automatic
calibration and removal of distortion from scenes of structured environments. Proc Soc Proc Inst Eng
1995; 2567: 62–72.
10. Wighton P, Lee TK, Atkins MS. Dermascopic hair disocclusion using inpainting. Proc Soc Proc Inst Eng
2008; 6914: 691427–6914278.
Address:
Tim K. Lee
Cancer Control Research and Cancer Imaging
BC Cancer Agency
675 West 10th Avenue
Vancouver, BC
Canada V5Z 1L3
e-mail: tlee@bccrc.ca
347