correcting image defects of stained glass windows
TRANSCRIPT
Correcting Image Defects of Stained Glass Windows
S. Suganthan,1 L. W. MacDonald2
1 School of Computing and Intelligent Systems, University of Ulster, United Kingdom
2 London College of Communication, University of Arts London, United Kingdom
Received 12 April 2007; accepted 27 May 2008
ABSTRACT: The main problem of photographing stained glass win-
dows is setting the correct exposure. An overall average exposure
setting frequently results in the highlight areas being overexposed, ordark area being under-exposed, or both. It is therefore necessary to
provide a suitable set of image processing tools to correct the image
defects. In this work describe several algorithms to solve this problemof nonuniformity of illumination. VVC 2008 Wiley Periodicals, Inc. Int
J Imaging Syst Technol, 18, 296–306, 2008; Published online in Wiley
InterScience (www.interscience.wiley.com). DOI 10.1002/ima.20160
Key words: exposure correction; image fusion; high dynamic range
imaging; stained glass image
I. INTRODUCTION
Image of stained glass windows are significantly different from
those of most other subjects because their color is generated by
transmitted, rather than reflected, light. Also, the medium has wider
dynamic range between the highlight and shadow area than most
‘‘real world’’ media. The main problem of photographing stained
glass windows is setting the correct exposure. An overall average
exposure setting frequently results in the highlight areas being over-
exposed, or the dark areas being underexposed, or both (Fig. 1). In
this work, several algorithms are described to solve this problem.
This is a kind of high dynamic range (HDR) (Ward, 2001; Xiao
et al., 2002; Reinhard et al., 2005; Xu et al., 2005) problem.
Dynamic range is the ratio between the highest and lowest values
that a signal can represent and as such is a dimensionless quantity.
In imaging, the dynamic range is the ratio of two luminance values,
expressed in candelas per square meter (cd/m2). The dynamic range
of real-world scenes can be quite high: ratios of 100,000:1 are com-
mon is the natural world (Table I). For example, in a scene showing
the dim interior of a room with a bright sunlit view outside the win-
dow, the dynamic range would be the ratio of the brightest point
outside to the darkest point inside. Human vision can adapt to the
full range of luminance encountered in the natural world, enabling
people to see under all conditions.
Most conventional digital cameras generate eight bits (256 lev-
els) for each of the three (RGB) primary channels and thus repre-
sent the color gamut of the image by 24 bits distributed in a three-
dimensional color space. Although 24-bit color is usually sufficient
for computer graphics and print reprographics, this limited range of
levels can lead to problems with photography. Often an eight-bit
range in each channel is not sufficient to capture all the highlight or
shadow detail present in a scene. Table II summarizes the case of
an RGB color image. Most digital cameras are able to capture only
a limited dynamic range. The exposure setting determines which
part of the total dynamic range is captured. A HDR image may be
created as a composite from a series of images of the same scene
taken under different exposure levels.
II. HISTOGRAM EQUALIZATION
The histogram of an image tells a lot about the distribution of gray
levels within the image. The perceived contrast and brightness of an
image can be determined directly from an image’s histogram. Fig-
ure 2 shows histograms corresponding to four basic image types.
Histogram techniques can also play an important role in the
enhancement of the perceived brightness and contrast of images,
for example, by taking a dark, low contrast image, and automati-
cally increasing its brightness and contrast, thereby exposing fea-
tures not visible in the original image. The histogram of an N 3 Mimage is defined as the percentage of pixels within the image at a
given gray level:
Hi ¼niNM
for 0 � i � 255 ð1Þ
where ni is the number of pixels at gray level i and NM is the total
number of pixels within the image. An important property of a his-
togram is that the sum of all histogram value over the range of gray
levels present within an image equals to one.
One technique that is used to enhance the brightness and con-
trast of an image is histogram equalization (Pitas, 2000; Gonzalez
and Woods, 2002). The goal of histogram equalization is to distrib-
ute the gray levels within an image, so that every level is equally
likely to occur. In other words, histogram equalization takes an
image’s histogram and produces a new image with a histogram that
is uniformly distributed. Because histogram equalization distributes
an image’s gray levels uniformly over the range of gray levels, all
resulting images will have approximately the same brightness andCorrespondence to: S. Suganthan; e-mail: [email protected]
' 2008 Wiley Periodicals, Inc.
contrast, thus allowing comparison of the images equally without a
bias due to perceived contrast and brightness differences.
Histogram equalization aims to change a picture in such a way
as to produce a picture with a flatter histogram, where all levels are
equiprobable. To equalize a color image, two methods are used:
1. Each of the three primary channels (red, green, and blue) is
equalized separately. Then the three channels are merged to
obtain the equalized image (Fig. 3).
2. The image is transformed into HSV color space. Only the V-
channel is equalized, then is merged with the unchanged H-
and V-channels (Fig. 4).
Histogram equalization uses the HSV color model, which is
clearly better in terms of image color rendering (Fig. 4).
III. EXPOSURE CORRECTION
A simulated camera response curve is used for exposure correction,
which gives an estimate of how light intensity values falling onto
the sensor are translated into final pixel values. Thus, it is a
function:
I ¼ f Sð Þ ð2Þ
where S represents the ‘‘light’’ quantity and I the final pixel value.
This exposure-density function (Bhukhanwala and Ramabadram,
1994; Mesina et al., 2003) can be expressed as
I ¼ f Sð Þ ¼ 255
1þ e�A3Sð3Þ
Which estimates how the incoming light intensities S (referred to as
exposure) are transformed by the camera’s sensor to pixel values I
as shown in the Eq. (3). The constant A is used to control the slope
of the curve, which appears as contrast level.
The three curves shown in Figure 5 demonstrate the relationship
between S and I with different values of A. The key idea of the ex-
posure correction method is to adjust the average exposure of the
image toward the ideal exposure, which in an eight-bit value corre-
sponds to the gray level of 128, and then to compute the final pixel
values using equations [Eq. (3)] with corrected exposures. The pro-
cess is performed on the entire image to preserve the image’s har-
mony in the following way.
� Calculate the difference between the ideal exposure and the
average exposure in the image:
Diff ¼ f�1 128ð Þ � f�1 AvgGrayð Þ ð4Þ
� For each pixel, re-expose it as follows:
S ¼ f�1 Ið Þ þ Diff ð5Þ
I0 ¼ f ðSÞ ð6Þ
Figure 1. This image of a stained glass window was taken with different f-stop settings at the Church of St. Mary, Studley Royal, Yorkshire,
UK, on 21 July 2004 using a high-resolution digital camera, consisting of Rollei 6008i medium-format camera body with a Jenoptik eyelike Preci-sion digital back. The Kodak CCD sensor has 4080 3 4080 pixels, with 16-bit depth per channel. [Color figure can be viewed in the online issue,
which is available at www.interscience.wiley.com.]
Table I. Typical scene luminance values.
Scenes Luminance (cd/m2)
Starlight 0.00001–0.001
Moonlight 0.001–1
Indoor lighting 1–100
Outdoor shade 100–10,000
Outdoor sunlight 10,000–1,000,000
Sun 108
Vol. 18, 296–306 (2008) 297
As shown in Figure 6, the quality of the typical underexposed
image (n 1 2-stop image) is obviously improved by exposure cor-
rection. Figure 7 illustrates how original pixel values I are trans-
formed to the final pixel values I.
IV. IMAGE FUSION
Image fusion is the process of combining information in all images
of a stained glass window to enhance understanding of the stained
glass. The method combines images captured at different exposures
into one image where all areas are well exposed. Goshtasby (2005)
presents a technique to do this, given a set of images of stained
glass obtained at constant shutter speed but different f-stop settings
(Fig. 1). The f-stop settings regulate how much light is admitted
through the lens by varying the area of the aperture. The image do-
main is subdivided into small disjoint blocks and for each block the
image containing the most information is selected. Then the
selected blocks are fused together to create a single image that is
well exposed everywhere. Under and overexposed areas in an
image carry less information than the well-exposed areas, so that
the process aims to select the best exposed image for each local
area (block).
An image is considered best exposed within a local area if it car-
ries more information than other images within that area. Using
image entropy (Gonzalez and Woods, 1993) may enable this.
Entropy is defined:
E ¼ �Xk�1
i¼0
HðiÞ log2½HðiÞ� ð7Þ
where H is the histogram. The higher the entropy of an image, the
more information the image will carry. An image that is under or over-
exposed within a block does not carry as much information as an
image that is well exposed in that block. So the algorithm is as follows:
1. The image domain is subdivided into small disjoint blocks.
2. Each RGB block (subimage) is transformed into HSV com-
ponents using the MATLAB function rgb2hsv. Consider V
channel.
3. Determine the entropy of block (V channel subimage) in
each image using formula in [Eq. (7)] find the highest en-
tropy block. Fuse the corresponding RGB blocks together to
create a single image.
Figure 2. Histograms corresponding to four basic image types.
Table II. Dynamic range and limiting factors for different bit depth.
Type of Digital Encoding
Bit Depth Per
Color Channel
Bit Depth
Per Pixel
Theoretical Maximum
Dynamic Range Limiting Factor
8-bit 8 24 256:1 Code quantising
12-bit 12 36 4096:1 Code quantising
14-bit 14 42 16384:1 Sensor noise
16-bit 16 48 65536:1 Dynamic range of capturing device
HDRI (e.g., radiance RGBE format) 32 96 Infinite Dynamic range of capturing device
298 Vol. 18, 296–306 (2008)
Figure 3. Histogram equalization using the RGB color model. [Color figure can be viewed in the online issue, which is available atwww.interscience.wiley.com.]
Vol. 18, 296–306 (2008) 299
Figure 8 shows the image obtained by composing the disjoint
blocks cut out of the eight images in Figure 1. Figure 9 shows
the output of this algorithm for four different block sizes. The
output images are more uniform and well-exposed than any of
the original images (Fig. 1), but they exhibit obvious discontinu-
ities across the block boundaries. Suitable blending functions
(Giani and MacDonald, 2003) may be used to overcome this
blocking effect.
Figure 4. Histogram equalization using HSV color model. [Color figure can be viewed in the online issue, which is available at
www.interscience.wiley.com.]
300 Vol. 18, 296–306 (2008)
V. FITTING BACKGROUND FUNCTION
The problem evident in the image sequence of Figure 1 is the non-
uniformity of the illumination. One solution to this problem is to
build an illumination profile. The average row illumination profile
of the image is shown in Figure 10. First, we assume that the illumi-
nation changes linearly by calculating a correction factor row-by-
row:
fi ¼ maxðyiÞ=yi ð8Þ
where i is the row number and yi is the value of fitting the illumina-
tion gradient.
Figure 5. Exposure curves with different values of parameter A.
Figure 6. Underexposed image (top) and the corrected result
(bottom). [Color figure can be viewed in the online issue, which isavailable at www.interscience.wiley.com.]
Figure 7. Tone curves for RGB channels. [Color figure can be
viewed in the online issue, which is available at www.interscience.
wiley.com.]
Figure 8. The image obtained by composing the blocks (the dis-joint block size is 102 3 102 pixels) cut out of the eight images (These
images are of size 1020 3 1020 pixels in Fig. 1). [Color figure can be
viewed in the online issue, which is available at www.interscience.wiley.com.]
Vol. 18, 296–306 (2008) 301
Figure 9. Images of size 1020 3 1020 pixels, obtained by composing the blocks cut out of the eight images in Figure 1, showing four different
block sizes. Top left: the block size is 102 3 102, top right: the block size is 10 3 10, bottom left: the block size is 51 3 51, and bottom right theblock size is 20 3 20. [Color figure can be viewed in the online issue, which is available at www.interscience.wiley.com.]
Figure 10. Top left: average row illumination profile and line of best fit; top right: original and corrected row illumination profiles; effect of linearillumination correction (bottom right) compared to the original image (bottom left). [Color figure can be viewed in the online issue, which is avail-
able at www.interscience.wiley.com.]
Figure 11. Top left: average row illumination profile and exponential fitting; top right: original and corrected row illumination profiles. Effect of
exponential illumination correction (bottom right) compared to the original image (bottom left). [Color figure can be viewed in the online issue,which is available at www.interscience.wiley.com.]
This profile is applied to the successive image rows by multiply-
ing the corresponding column by the correction factor. Results are
shown in Figure 10.
In Figure 10, the average row illumination profile appears to be
more like an exponential than a linear distribution. So, to fit a func-
tional form:
y ¼ AeBx ð9Þ
Equation 9 should take the logarithm, that is,
ln y ¼ lnAþ Bx ð10Þ
The best-fit values are then
a ¼
Pni¼1
ln yiPni¼1
x2i �Pni¼1
xiPni¼1
xi ln yi
nPni¼1
x2i �Pni¼1
xi
� �2ð11Þ
A ¼ expðaÞ ð12Þ
B ¼nPni¼1
xi ln yi �Pni¼1
xiPni¼1
ln yi
nPni¼1
x2i �Pni¼1
xi
� �2ð13Þ
Figure 11 shows the correction factor calculated using the exponen-
tial fitting of average row illumination data.
The linear and exponential fitting illumination correction meth-
ods described earlier are based on building a 1D illumination pro-
file. This approach is not suitable for all images, and a better
approach is to build a 2D illumination profile based on the average
illumination of both rows and columns. The 2D illumination distri-
bution B(i,j) is calculated as follows:
Bði; jÞ ¼ ðrowðiÞ þ colðjÞÞ2
ð14Þ
Vol. 18, 296–306 (2008) 303
where row(i) and col(j) are the average row and average row and
average column illumination distributions respectively. This 2D
illumination profile is employed by calculating a pixel-by-pixel cor-
rection factor:
fij ¼maxðBði; jÞÞ
Bði; jÞ ð15Þ
This method was applied to the successive images, multiplying
each pixel by the corresponding correction factor.
Figure 12. Results of five correction methods compared to the original image. [Color figure can be viewed in the online issue, which is avail-
able at www.interscience.wiley.com.]
304 Vol. 18, 296–306 (2008)
VI. CONCLUSIONS
In this work, several algorithms have been presented to solve
the stained glass exposure setting (or dynamic range) problem. Fig-
ure 12 shows the results of five different methods compared to the
original images.
When histogram equalization was used to increase image con-
trast the image color and hue were changed. The next algorithm for
exposure correction adjusted the average exposure of the area of in-
terest toward the ideal exposure. This algorithm gave a reasonable
degree of success, but the top part of the image remained bright and
the bottom part dark, because of nonuniform illumination. The
image fusion method gave more acceptable results but produced
block defects. These were the overcome with the aid of some blend-
ing functions. The image fusion algorithm also took a lot of
Figure 13. Results of 2D background illumination correction algorithm (right) compared to original images (left). [Color figure can be viewed in
the online issue, which is available at www.interscience.wiley.com.]
Vol. 18, 296–306 (2008) 305
computing time. Finally, a simple algorithm was developed to build
a 2D illumination profile, from which a pixel-by-pixel correction
factor was derived. The results of the final 2D background illumina-
tion correction algorithm applied to three test images are shown in
Figure 13. The resultant images are visibly more pleasing, and this
algorithm seems to have successfully overcome this problem of
nonuniformity of illumination. Some artifacts remain visible, how-
ever, in the image areas covering the surrounding masonry.
REFERENCES
S.A. Bhukhanwala and T.V. Ramabadram, Automated global enhancement
of digitized photographs, IEEE Trans Consum Electron 40 (1994), 1–10.
A. Giani and L.W. MacDonald, Blending images of stained glass windows,
Proc IS&T/SID 11th Color Imaging Conf, Scottsdale, 2003.
R.C. Gonzalez and R.E. Woods, Digital image processing, Addison-Wesley,
1993.
R.C. Gonzalez and R.E. Woods, Digital image processing, 2nd ed., Prentice
Hall, 2002.
A.A. Goshtasby, 2-D and 3-D Image registration for medical, remote sens-
ing and industrial applications, Wiley, 2005.
G. Mesina, A. Castorina, S. Battiato, and A. Bosco, Image quality improve-
ment by adaptive exposure correction techniques, Proc ICME 2003, 2003,
pp. 549–552.
I. Pitas, Digital image processing algorithms and applications, Wiley, 2000.
E. Reinhard, G.Ward, S.N. Pattanaik, and P. Debevec, High dynamic range imag-
ing: Acquisition, display, and image-based lighting,Morgan Kaufman, 2005.
G. Ward, High dynamic range imaging, Proc Ninth IS&T/SID Color Imag-
ing Conf, Scotsdale, November 2001.
F. Xiao, J.M. DiCarlo, P.B. Catrysse, and B.A. Wandell, High dynamic
range imaging of natural scenes, Proc 10th IS&T/SID Color Imaging Conf,
Scottsdale, 2002, pp. 337–342.
R. Xu, S.N. Pattanaik, and C. Hughes, High-dynamic-range still-image
encoding in JPEG 2000, IEEE Comput Graph Appl 25 (2005), 57–64.
306 Vol. 18, 296–306 (2008)