16
COMPUTER VISION, GRAPHICS, AND IMAGE PROCESSING &236-251 (1984) Image Enhancement Using the Median and the Interquartile Distance IRWIN SCOLLAR AND BERND WEIDNER Image Processing Laboratory Rheinisches Landesmuwum, Bonn, West Germany AND THOMAS S. HUANG Coordinated Science Laboratory, University of Illinois, Urbana-Champaign, Illinois 61801* Received October 30,1982; revised December 3,1982 Enhancement and noise cleaning algorithms based on local medians and interquartile distances are more effective than those using local means and standard deviations for the removal of spikelike noise, preserve edge sharpness better, and introduce fewer artifacts around high contrast edges present in the original data. They are usually not as fast as the mean-stan- dard deviation equivalents, but all are suitable for large data sets to be treated in small machines in production quantities. 1. INTRODUCTION Many effective image enhancement algorithms make use of local statistics in a window of moderate size [l}. Such techniques are useful for noise cleaning, crispen- ing, and adaptive contrast and brightness correction. In most cases the local statistics used are the mean and standard deviation of the pixels in a square or rectangular window. It is the goal of the present paper to show that, for certain classes of images, better results can be obtained if we replace the local mean and standard deviation by the local median and interquartile distance, respectively. Specifically, this replacement is desirable if the image contains high contrast edges or noise with heavy tailed probability density functions (pdf), especially spike- or pointlike noise, or its two dimensional analog which we will call thread noise because the noise looks like fuzz or threads in the image. It will be seen that the use of the median and the interquartile distance is more effective in removing such noise, in preserving edge sharpness, and in avoiding the introduction of artifacts on high contrast edges (light or dark banding). The images for which our enhancement algorithms were developed have inher- ently high resolution and large numbers of pixels. They are oblique aerial photo- graphs of rural areas which show the outlines of buried archaeological sites as discolorations in growing crops or soils; metallographic X-ray pictures of corroded objects from archaeological excavations prior to restoration, infrared and ultraviolet images of paintings and other art objects; and thermal infrared scans made from the air to map buried ancient field systems. The users of such imagery demand hard copy of the highest quality without visible scan lines and with full photographic gray scale. To achieve this, most pictures are scanned with between two and four thousand lines at equivalent pixel resolution, resulting in data which are typically 4 *On leave at the Image Processing Laboratory, Rheinkches Landesmuseum, Bonn, under the auspices of the A. von Humboldt Stiftung, BOM, West Germany. 236 0734189X/84 $3.00 c~pyri%t 0 1984 by Academic Press, Inc. All rights Of reproduction in any form reserved.

Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

COMPUTER VISION, GRAPHICS, AND IMAGE PROCESSING &236-251 (1984)

Image Enhancement Using the Median and the Interquartile Distance

IRWIN SCOLLAR AND BERND WEIDNER

Image Processing Laboratory Rheinisches Landesmuwum, Bonn, West Germany

AND

THOMAS S. HUANG

Coordinated Science Laboratory, University of Illinois, Urbana-Champaign, Illinois 61801*

Received October 30,1982; revised December 3,1982

Enhancement and noise cleaning algorithms based on local medians and interquartile distances are more effective than those using local means and standard deviations for the removal of spikelike noise, preserve edge sharpness better, and introduce fewer artifacts around high contrast edges present in the original data. They are usually not as fast as the mean-stan- dard deviation equivalents, but all are suitable for large data sets to be treated in small machines in production quantities.

1. INTRODUCTION

Many effective image enhancement algorithms make use of local statistics in a window of moderate size [l}. Such techniques are useful for noise cleaning, crispen- ing, and adaptive contrast and brightness correction. In most cases the local statistics used are the mean and standard deviation of the pixels in a square or rectangular window. It is the goal of the present paper to show that, for certain classes of images, better results can be obtained if we replace the local mean and standard deviation by the local median and interquartile distance, respectively. Specifically, this replacement is desirable if the image contains high contrast edges or noise with heavy tailed probability density functions (pdf), especially spike- or pointlike noise, or its two dimensional analog which we will call thread noise because the noise looks like fuzz or threads in the image. It will be seen that the use of the median and the interquartile distance is more effective in removing such noise, in preserving edge sharpness, and in avoiding the introduction of artifacts on high contrast edges (light or dark banding).

The images for which our enhancement algorithms were developed have inher- ently high resolution and large numbers of pixels. They are oblique aerial photo- graphs of rural areas which show the outlines of buried archaeological sites as discolorations in growing crops or soils; metallographic X-ray pictures of corroded objects from archaeological excavations prior to restoration, infrared and ultraviolet images of paintings and other art objects; and thermal infrared scans made from the air to map buried ancient field systems. The users of such imagery demand hard copy of the highest quality without visible scan lines and with full photographic gray scale. To achieve this, most pictures are scanned with between two and four thousand lines at equivalent pixel resolution, resulting in data which are typically 4

*On leave at the Image Processing Laboratory, Rheinkches Landesmuseum, Bonn, under the auspices of the A. von Humboldt Stiftung, BOM, West Germany.

236 0734189X/84 $3.00 c~pyri%t 0 1984 by Academic Press, Inc. All rights Of reproduction in any form reserved.

Page 2: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

ENHANCEMENT USING THE MEDIAN 237

to 16 Mbytes per image. Production quantities must be processed at our installation. In such images, high spatial frequency but low contrast information is of great interest, but high contrast edges of objects of no interest are widely present. These edges may be modem field boundaries, roads, or structures, while the objects of interest have low contrast and are near the edges.

Most of our pictures were obtained under unique conditions in the past and they cannot be repeated. Defects in such images are typically due to dirt and stratches on negatives because of improper storage or lack of care during processing, under- or overexposure in spatially varying amounts, very low or very high brightness with the information of interest restricted to a small part of the range, positionally depen- dent. Most pictures are on black and white aerial or X-ray film, some are direct recordings on magnetic tape from nonfilm sensors, some on 35mm film of all possible types. We have not processed the color pictures directly because we lack suitable hardware, but black and white color separation negatives from color slides have been treated.

Apart from the above, noise in our images is also due to film grain or scanner photomultiplier noise, and these are usually Gaussian. Most types are usually present in an image at once. Signals are usually fine linelike structures with complex geometries or irregularly shaped blobs, all identifiable as man-made when seen by a trained observer. The aim of enhancement is to help him make the appropriate pattern recognition decisions by reinforcing the ability of the human eye to detect faint geometric structures in noisy backgrounds. Because of the very high resolution demanded and given the quantities of pictures to be processed, algorithms must be fast enough to keep up with picture input-output. Given the financial limitations, a large fast machine may not be used. The algorithms discussed in this paper possess the required properties and have been used successfully for a number of years.

2. PROPERTIES OF THE MEDIAN AND THE INTERQUARTILE DISTANCE

Let us first establish our notation.

f(i, i) = brightness at point (i, j) in the image. Local mean (window size (2k + 1) x (2k + 1)):

Local standard deviation: l/2

a(i, j) = 1

(2k + 1)’ .

Let pij(f) be the sample cumulative distribution function of

{f(i - u, j - u)lu = -k ,..., 0 ,..., k; u = -k ,..., 0 ,..., k}.

Local median:

M(i, j) = pFc, such that Pii = l/2

Page 3: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

238 SCOLLAR, WEIDNER, AND HUANG

Local interquartile distance:

Q(i, j) = Y - A

where Pii = 3/4 and Pii = l/4. Note that if p is not unique, we take M(i, j) as the midpoint of the range of ~1; similarly for h and V. Note also that for the sake of simplicity we have used a square window, but generally the window may be of any shape: rectangular, cross, ring, etc.

It is well known that the local median has the following properties [2]:

(1) It tends to preserve sharp edges. In particular, the edges in an image are much better preserved in M(i, j) than in m(i, j) (see Section 8).

(2) It tends to eliminate spike noise. More generally, the situation is as follows: let us consider the simple case where the signal part of the image is constant and zero, and the noise is zero mean, independent from sample to sample, and identically distributed with some probability density function. Then

E[+, j)] =f(i, j) = E[M(k Al and the variances ui and I& can be used as measures of the noise cleaning power of the running mean and median filters. The smaller the remaining variance is, the more the noise filter has removed.

It is well known that for Gaussian noise

for a window of fixed size, of course, while for Laplacian noise (double-sided exponential) it has been observed empirically that uz > &. Generally, it has been observed empirically that when the tails of the probability density function of the noise become heavier, the running median filter becomes more effective relative to the running mean filter. A particular example is the case when the probability density function of the noise is of the form

where A, a, and (Y are positive constants; then it can be readily shown that as (Y decreases (i.e., the tails of the pdf become heavier), (uz - I&) increases.

A similar comparison exists between the variabilities of the local standard deviation and the local quartile distances. As the tails of the noise pdf become heavier, (u,’ - yu4) increases (where y is a constant inserted to make E[dyQ] equal to the standard deviation of the noise pdf. As shown in Section 8 of this paper, the interquartile distance is used as a good approximation to the absolute deviation from the mean, a measure of dispersion which is the order statistics analog of the standard deviation. The interquartile distance is much easier to compute than the absolute deviation, and for the data in question they seldom differ by more than a few percent, judging from empirical observation. A more detailed analysis of the advantages of order-based measures with regard to spike noise is given in Section 8.

Page 4: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

ENHANCEMENT USING THE MEDIAN 239

3. COMPUTATIONAL REQUIREMENTS

Assume that we are calculating m(i, j), a(& j), M(i, j), Q(i, j) for the entire image. Let the window size be A x B. It is well known that the local mean m(i, j) can be calculated using four additions per output point in a recursive manner independently of the window size [3, 41. One takes advantage of the separability of the two dimensional mean and does the calculation in one direction at a time; this is done recursively which requires only two additions per output point.

The local standard deviation a(& j) can be calculated similarly. The recursive operation also needs four additions per output point, but we also need to subtract m(i, j) from each input point and square the result. After the recursion we need to take the square root, so that the total number of operations required per output point are five additions/subtractions, one multiplication for squaring, and one square root, independently of window size.

To calculate the local median using the Huang-Yang-Tang histogram update algorithm [5] requires approximately 2A comparisons and 2A additions per output point. If we calculate the interquartile distance Q(i, j) at the same time we need 4A additional comparisons. If we calculate the separable median [6], we must compute it in one dimension horizontally, then vertically on the result. The computational requirement is then nearly the same as for the mean: four additions and four comparisons per output point independent of window size. However, the separable median is similar but not identical to the two dimensional median. For the same window size, the separable median removes less noise but preserves sharp comers better. Storage requirements are much greater, as we shall see in Section 4.

Algorithms based on means and standard deviations are the fastest known for local enhancement and filtering, sometimes called box filtering [4]. Median methods may soon equal these since several companies are constructing VLSI chips for video-rate two dimensional median filtering. The initial work involves only small 3 x 3 or 5 x 5 windows, and interquartile distances have not been mentioned. When completed, with larger windows and the interquartile distances, this effort will bring down throughput times to video rates.

A multipass algorithm for local enhancement using the median in place of the mean and the median absolute deviation (MAD) as a dispersion measure is sug- gested in [7]. To calculate the MAD it is necessary to produce a median filtered image, subtract it from the original, and then median filter the absolute differences. This requires three passes through the data plus two calculations of a median per point. A reduction in calculation can be obtained by using only the absolute deviation from the median as the dispersion measure instead of the MAD. Since the algorithm of [5] lends itself to simultaneous calculation of the interquartile distance as well as the median in one pass through the data, there seems to be no reason to use a multipass method in a nonhardware implementation.

For very high resolution images (greater than 1500 lines, 1500 pixels per line) where the eye cannot see the scan structure at normal viewing distances, algorithms based on these techniques are the only practical ones for serial computers of modest speed and storage capability. The results cannot usually be distinguished by laymen from those obtained by more complex algorithms which can be implemented only on large machines when throughput time is important. Mean-standard deviation meth- ods can usually be used if more than 400 pixels are available for the moving window. For 400 pixels or more defined to 256 levels, the median approaches the mean very

Page 5: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

240 SCOLLAR, WEIDNER, AND HUANG

closely for nearly all typical pdf’s encountered except at very sharp broad edges. Hence it is seldom of interest to use median based methods for windows larger than 19 X 19 unless the window is sampled. We have -obtained much faster computing times with larger windows, rather than the reverse, once the window contains more than 400 values, by sampling at suitable intervals.

4. STORAGE REQUIREMENTS

In the case of the separable median, the computer must have enough directly addressable memory to store the entire input image or a very large part of it. In the normal two dimensional median technique using the Huang-Yang-Tang algorithm, a portion of the image in the vertical direction equal in size to the window height plus one additional line must be stored in a circular buffer at least. In the separable mean-standard deviation approach, only the upper, center, and lower picture lines of the strip in which the window moves need be stored, together with two accumu- lator arrays, one for the column sums of the moving window and one for the sums of squares. The latter usually needs twice the word length of the first. In all cases only one output line need be stored. Use of asynchronous input/output techniques which in our installation materially increase the speed of throughput require additional storage capabilities for the input and output data lines. Given the modest storage and word lengths of many micros and lower range minis, there is usually no way to implement the separable median for high resolution images directly. It can be done in two passes from the disks but the extra I/O time usually wipes out any advantage. Only the property of comer preservation may be a reason for its occasional use. We have programmed all algorithms described in this paper to work with at least 2000 line/pixel images and in some cases with 4000 line/pixel images in only 64K bytes of storage, including buffers for asynchronous input-output.

5. ALGORITHMS FOR NOISE CLEANING

Let f( i, j) be the input image and g( i, j) the output image. We first list a number of simple algorithms for noise cleaning using local mean and standard deviation. Examples are shown in Fig. 1.

Algorithm Nl, simple averaging:

g(i, i) = m(i, i).

Algorithm N2, averagingwith fixed threshold [8, 91:

g(i, i) = 44 i) if If(i, j) - m(i, j)l > t,

= f (i, i) if lf(i, j) - m(i, j)l 5 t

where t is a threshold supplied interactively. Algorithm N3, averaging with variable threshold depending on contrast:

g(i, j) = m(i, j) if If(i, j) - m(i, j)l > Mi, j>, =f(i, j) if If (k j) - m(i, Al 5 Ba(i, i)

where B is a constant.

Page 6: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

ENHANCEMENT USING THE MEDIAN 241

FIG. 1. Noise cleaning using local averaging (algorithms Nl-3); 2000 line images, 7 x 7 window. N2: threshold lo%, N3: B = 1.5.

Algorithm Nl is used to smooth random Gaussian noise. It blurs edges. Algorithm N2 can be used with a window much larger than the noise features to smooth spike or thread noise. If t is well chosen, it may not blur edges as much as Nl. Algorithm N3 is a sign&ant improvement on N2 since the usual outlier criterion of 95% confidence limits in elementary statistics is satisfied when /I = 2. In N2, if t is chosen too large, then noise cleaning will not be good; if too small, edges will be blurred. N3 adapts to local contrast in the data, and sharp edges will hardly be blurred at all, providing that the window is large enough. More complicated algorithms have been proposed which can preserve edge sharpness, but they do not have the computa- tional advantage of Nl, N2, or N3 [lo].

We propose here an alternative approach to high contrast edge preservation with small windows in the presence of spike or thread noise. In algorithms Nl-3 replace the local mean m(i, j) by the local median M(i, j) and the local standard deviation

Page 7: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

242 SCOLLAR, WEIDNER, AND HUANG

FIG. 2. Noise cleaning using local median (algorithms N’l-3). Parameters as in Fig. 1.

u by the local interquartile distance Q(i, j) as an approximation to the local absolute difference. We call the three new algorithms Nl’, N2’, and N3’. Results using this substitution are shown in Fig. 2 for the data of Fig. 1. Algorithm N3’ is superior to algorithm N3 in removing spike noise and preserving edge sharpness since smaller windows can be used, the median and quartile differences being less alkted than the mean and standard deviation. Empirically we have observed that two- or threefold size reductions are possible. Algorithm Nl’ is superior to Nl in preserving edge sharpness, but the relative abilities of Nl and Nl’ depend on the noise pdf. Both Nl’ and N3’ will remove spike noise, but edge sharpness is better preserved by N3’, while Nl’ will remove more Gaussian noise. If large windows are used, comers will be better preserved with N3 than with N3’ using the two dimensional median. Performance is roughly the same using the separable median. For large windows N3 is the preferred algorithm; for small windows N3’. Artifacts with large windowed N3 runs may sometimes be objectionable on very large edges.

Page 8: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

ENHANCEMENT USING THE MEDIAN 243

6. ALGORITHMS FOR CRISPENING

By crispening we mean an apparent sharpening of the image without change of local brightness or contrast [ll]. A very effective algorithm which we have used most extensively because of its high speed is a variant on box filtering with roll-off control and brightness normalization.

Algorithm C

g(i, j) = w{ f(i, j) - am(i, j))

where (Y is a constant, 0 < a < 1, and w is a brightness normalization constant which depends on the window size and the value of (Y. The frequency response of this linear spatially invariant filter depends on the constant (Y and the window size used in computing the local mean m(i, j). The larger the value of (Y the greater the crispening effect. The larger the window size, the more the effect is obtained over broader edges. However, for very high contrast edges already present in the picture, there is some overshoot which results in light or dark banding which may be objectionable when large window sizes are used. This is shown in Fig. 3. A large window size should be used to obtain stable means in noisy areas, but then the effect is most noticeable.

To overcome this we recommend replacing the local mean by the local median to get our algorithm C’. For the same value of a and the same window size, algorithm C’ will crispen the image slightly less but this is hardly observable (Fig. 3). It is possible to combine crispening and noise cleaning in one pass. Algorithm C’ can be combined with N3’, C with N3, or mixtures of the two types used. For example, see the following.

Algorithm C’N3’

g(i, i) = M(i, j) if V(i, j) - M(i, j)l > PQ(i, j), = w{ f(i, j) - aM(i, i)} iflf(i, j) - M(i, j)l < PQ(i, i).

It has been observed that crispening followed by noise cleaning in a two-pass algorithm is superior to the above or to the reverse order, because spike noise is first exaggerated by C’ and moved to the outer tail of the pdf where it can be removed more easily by N3’. It is useful to use C instead of C’ in the first pass to save time. Because of the variant data structures required, it is not useful to program this combination for a single pass.

In general, it is desirable to use different window sizes for the crispening and cleaning parts of the treatment. Usually a smaller window for the crispening is desirable. This increases the storage requirements for CN3 since extra image lines have to be buffered and multiple accumtdators are needed. This is not the case for C’N3’ where a large circular buffer for the big window is available anyway. Despite the slower computational speed, the I/O saving is considerable. Multiple window versions of these algorithms can be combined to give bandpass and Gaussian filtering and are computationally effective, especially with the possible variants of

Page 9: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

244 SCOLLAR, WEIDNER, AND HUANG

FIG. 3. Crispening using local averaging and local median; 2000 line images, 7 X 7 window.

algorithm C. There is some advantage, as pointed out in [12], in the sequential combination CC’ with values of a! equal to 1 and a larger window size for C than for C’ as a noise insensitive edge extractor.

We also wish to note that a simple modification of C or C’ can be used for reduction of linear motion blur if it is uniform over the image and more or less at right angles or parallel to the scan direction. It is merely necessary to displace the central pixel in the window by a small amount depending on the direction of blur. Usually it is advantageous to use a rectangular window with the long axis parallel to .the blur direction. Blur which is not -parallel to the scan direction ought to be reducible with displacement at some angle from the true center. Large amounts of blur cannot be dealt with by this technique. Blur which is not uniform over the image might be dealt with by varying the amount and direction of offset over the image, but I we have not tried this. ..Here there will be a complex problem in determining the needed displacement and varying window sizes.

Page 10: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

ENHANCEMENT USING THE MEDIAN 245

7. ALGORITHMS FOR LOCAL CONTRAST AND BRIGHTNESS ENHANCEMENT

These algorithms are needed for exposure and development correction, especially in spatially variant cases which cannot be treated by simple histogram transforma- tion of the entire image. One approach to enhance local contrast is to normalize the local standard deviation to some constant, a kind of automatic gain control [13]. Another possibility is raising the local standard deviation by multiplying the mean-pixel difference by a constant and replacing part of the output pixel [14]. The most satisfactory scheme which we have used judging by user acceptance has been that due to Wallis [15], as follows.

Algorithm W

g(i, j) = Au(if; + ud { f(i, j) - m(it d} + amd +tl - a>m(i? j)

where md = a desired mean, ed = a desired standard deviation, A is a gain or contrast expansion constant (usually 4 < A < 20), and a is a brightness forcing constant, usually 0 < a < 0.3. This algorithm can be improved by limiting either the maximum observed standard deviation a(i, j) or the value of the pixels which contribute to it as suggested in [l]. The first is computationally preferable. Perfor- mance on high contrast edges is helped by this modification, reducing the edge artifacts somewhat; see Fig. 4.

Experimentally, it has been found that good results which do not add noise to the image require windows of the order of 5 to 10% of the side length. Noise effects which have been noted [l] are due to the use of windows which are too small, giving consequent instability in the standard deviation in the presence of heavy-tailed pdf’s. However, if the image contains high contrast edges, then a large window will introduce dark or light bands along the edges; see Fig. 4. This artifact can be considerably reduced (Fig. 4) if we replace m and u by M and Q giving algorithm W ‘. The local contrast and brightness correction of W ’ are indistinguishable from W for the same window sire, but since smaller windows can be used, banding effects are less. Noise effects are the same since such large windows must be used for W. Very small windows produce a bit more noise in W than in W’, but on very high resolution images it is sometimes difficult to see the difference except in highly uniform gray areas.

We have obtained a considerable speedup of W by using a regularly sampled window for those larger than 20 x 20 pixels. Presumably, this approach could also be applied to W’ but it does not appear to be worthwhile, since there is little difference in performance for the two algorithms in the noise sense when windows are so large. Only the difference in edge banding justifies the extra computational cost of W’.

8. ERROR NORMS AND ENHANCEMENT OPERATORS

The analogies between means, standard deviations, medians, and quartile differ- ences used throughout this paper are difficult to understand with standard filtering theory. We propose that they can best be understood in terms of error norms and their associated dispersion measures. For this we must introduce a few theoretical concepts.

Page 11: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

246 SCOLLAR, WEIDNER, AND HUANG

FIG. 4. Local contrast and brightness enhancement (algorithms W and W’) W window 50 x 50, av. = 127 (on 255 scale), (I = 50, a = 0.1, A = 20; W’ window 11 X 11. Same parameters for median and quartile difference as in W.

A set is called a metric space if, for every pair of elements, a real distance is defined with satisfies the following conditions:

4x9 Y) > 09 while d(x, y) = 0 ifandonlyifx =y;

d(x, y) = &Y, x);

d(x, z) < d(x9 Y) + d(Y, z) triangle inequality.

An important class of distance functions is generated by norms. A norm 11 11 on a

Page 12: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

ENMCEmT USING THE MEDIAN 247

linear space is a real function which satisfies the following axioms:

PII h 03 while llxll = 0 ifandonlyifx = 0

II4 = lal . llxll for every number a

lb + YII 5 Ilxll + IIYII

4x9 Y) = lb - YIl*

In particular the L, or Minkowsky norms are defined as

L,(a, b) = ( jblx(t)l’dr)? a

Now, for our statistical measures, let p be a pdf defined on the interval I:= [-&in, -&ax ] and P be the corresponding cumulative distribution function or proba- bility function. The expected value of a function f is then detined as

E(f):= if dP.

Let the dispersion of p around y E I with regard to the L, norm be

The value

d,(y):= {ax - Yl’)I”’ lsr<ao.

d,:= $nd,( y)

is called the dispersion of p with regard to the L, norm or simply the r dispersion of p. If there is a unique c, E I which minimizes d,(y) such that

it will be called the r center of p. Let us now consider a few special cases:

r = 2 (the Euclidean Norm); E(x - y)’ = min,

* 9 = E(x),

the mean value of p and

d, = (E((x - E(x))~))~‘~,

the standard deviation of p. This norm underlies all classical statistics and linear transform theory.

r + co (Max Norm); in this case d,(y) converges to

d,(y) = ~e~lx - YI

Page 13: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

248 SCOLLAR, WEIDNER, AND HUANG

independently of p such that

the half range, and

r = 1 (Manhattan or City Block Norm); E( lx - ~1) = min *

/ x~h~(y-x)dP+~x=-~(x-y)dP=o* [,dP=[-dP=i since@‘=~.

IlUll

The value ci with

is just the median and d, = E( Ix - ci I) is the absolute deviation from the median. Because these measures are dehned in terms of the L, norm, attempts to study their properties using classical transform theory which depends on the L, norm will fail.

For d, another expression can be derived:

d,= j”(q- &in

x)dP+[;-(x-q)dP= jX-xdPf,xdP. Cl OM

Now let

pl= 2P9 x 2 Cl md pr = 0, x 5 Cl,

= 0, x > Cl = 2P, x > Cl

be the left and right half distributions of p, respectively; then dl = l/2{ Epr(x) - E,,(x)}, i.e., the difference of the mean values of the two half distributions, which can be written, using the notation c,(p) for the r center of p,

4 = :(cz(~r) - c,(~l))-

It now seems natural to define, in an analogous manner,

Q:= t(c,< pr) - c~( Al))

with ci( pr) and ci( pl) as the medians of the half-distributions having the obvious properties

J s(p”dp

xmim I c$dJ’ = cp 5 jxm” dp = 4

1 1 cl(Pr)

and are called the quartiles of p.

Page 14: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

ENHANCEMENT USING THE MEDIAN 249

2Q is then called the interquartile distance. Let q1 = cr( pl), q2 = ct( p), q3 = cl( pr). To see what effect spikes in the data

have, we may interpret p as a frequency distribution of samples and consider what happens if a small fraction h of samples is replaced by new samples with a fixed value z. Let p’ be the distribution of samples replaced with /dP’ = h, the fraction replaced. We also assume that the samples replaced are taken randomly, such that, approximately,

p’ = hp and that z B cl.

We then have

c; = (1 - h)c, + hz.

For the median c1

1 -= 2

1'; d(P - p') = /" d(P - P') + /“d(P - P’) Xmin XtN” Cl

= 9 +(I - h)l’;dP = 9 +(l - h)P(c, 5 x 5 c;) (‘1

=y+(l-h)(P(x+;)

1 1 -P(X~c;)=~~.

Analogous relations hold for the quartiles, so that for i = 1,2,3,

P(X 5 q() = $A = $1 + h)

for small h and

Q’ = $( P-‘(a(1 + h)) - P-‘(a(1 + h)).

All these relations are independent of z and give corrections only on the order of h, whereas the change for c2 is of the order hz. For spike, thread, and comparable “singularity” noise in pictures h, the fraction of spikes seen in a window is small ( < 0.1) whereas lz - ci 1 is usually quite big. In that case, as has been shown, the median and interquartile distance give much more noise tolerant estimates of local brightness and contrast than do the mean and standard deviation.

IDefIning an edge as two adjacent areas with Gaussian distributions having different means and perhaps different standard deviations, let us examine what happens in a window when it passes over this edge, starting well out in the first area. When the window just touches the edge, the pixels belonging to the second distribution appear as singularities in the sense defined above (spikes or threads).

Page 15: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

250 SCOLLAR, WEIDNER, AND HUANG

Therefore the value of the median does not change immediately. It does change when the number of new pixels from the second distribution becomes a significant fraction of the total number in the window. This is why the normal type of median filtering blurs the edge less than does filtering with the mean.

Given the advantages of the L, norm based measures, one would like to think that a theory of filtering could be built up using this norm by analogy with linear Wiener filtering which is based on an L, norm. L, norm filtering is based on the fact that the L, norm is derivable from a scalar product such that the notion of orthogonality is well defined. Unfortunately this is not the case with the L, norm. Classical filtering (Fourier, Hadamard, etc.) is efficient because of the analytical tractability of the L, norm approximations or estimates of a function. L, norm approximations to a function can only be obtained with linear programming techniques. This is not efficient, although filtering approaches using them are possible. As far as we know, using the median, quartile difference approach is the only efficient way to take advantage of the properties of the L, norm without using linear programming or something still worse.

9. CONCLUSIONS

We have shown that, for certain types of images, the use of the local median and the interquartile distance is more effective than the use of the local mean and standard deviation at the expense of computation time unless the complete image can be stored. In this case separable medians and quartile differences restore the time advantage or even gain something since no squares or square roots are needed. Specifically, algorithms using M and Q have the following general advantages:

(1) They are more effective in removing spike noise or noise with a heavy tailed pdf.

(2) They preserve edge sharpness better. (3) They introduce fewer artifacts around high contrast edges already present in

the original data.

On the negative side they are generally slower to compute in a small general purpose machine. When VLSI chips for the median are available, video-rate operations will be possible. Combined algorithms with one pass through the data are presently a worthwhile improvement in serial machines, but the order of operations is important and different effects can be achieved with multipass algorithms depending on what is done first. The suite of algorithms is especially suitable for production quantities of high resolution images without excessive amounts of noise in an application environ- ment, without the use of high-cost machines.

REFERENCES 1. J. S. Lee, Digital image enhancement and noise filtering by use of local statistics, IEEE Truns. Pattern

Anal. Much. Intell. PAMI-2, 1980. 165-168; Refined filtering of image noise using local statistics, Computer Graphics Image Processing 15, 1981. 380-389.

2. T. S. Huang. ed.. Two-Dimensional Digitul Signal Processing II: Transforms and Mediun Filters, Chaps. 1, 5. 6. Springer-Verlag, New York/Heidelberg.

3. J. M. Soha et al., Computer techniques for geological applications, Proceedings, Caltech/JPL Conference on Image Processing, Nov. 3-5, 1976, JPL SP 43-30, Sect. 4-1.

4. M. J. McDonnell, Box filtering techniques, Computer Graphics Image Processing 17, 1981. 65-70.

Page 16: Image Enhancement Using the Median and the Interquartile Distanceftp.uni-koeln.de/pc/basp/Scollar-Weidner-Huang.pdf · 2012-08-15 · of the median and the interquartile distance

ENHANCEMENT USING THE MEDIAN 251

5. T. S. Huang, G. J. Yang, and G. Y. Tang, A fast two-dimensional median filtering algorithm, IEEE Trans. Acoust. Speech Signal Process. ASSP-21, 1979, 13-18.

6. P. M. Narendra, A separable median filter for image noise smoothing. Proceedings, IEEE Conference on Pattern Recognition and Image Processing, 1978, pp. 137-141.

7. R. T. Gray, D. C. McCaughy, and B. R. Hunt, Median masking technique for the enhancement of digital images. Proc. SPIE Annu. Tech. Symp. 24l7, 1979,142-145.

8. R. E. Graham, Snow removal-A noise-stripping process for picture signals, IRE Trans. If. Theov IT-& 1966,129-144.

9. J. M. S. Prewitt, Object enhancement and extraction, in Picture Processing and Psychopictorics (B. S. Lipkin and A. Rosenfeld, Eds.), Academic Press, New York, 1970.

10. M. Nagao and T. Matsuyama, Edge preserving smoothing, Computer Graphics Image Processing 9, 1979, 394-407.

11. W. K. Pratt, Digital Image Processing, pp. 322-323, Wiley-Interscience, New York, 1978. 12. B. J. Schachter and A. Rosenfeld, Some new methods of detecting step edges in digital pictures,

Commun. Assoc. Comput. Mach. 21, 1978, 172-176. 13. A. H. Watkins, EROS Data Center image processing technology, Proceedings, Caltech/JPL Con-

ference on Image Processing, Nov. 3-5, 1976, Sect. 16-3. 14. J. S. Lee, Digital image processing by use of local statistics, Proceedings, IEEE Conference on Pattern

Recognition and Image Processing, 1978, p. 56, Eq. (4). 15. R. Wallis, An approach to the space-variant restoration and enhancement of images, in Image Science

Mathematics (C. 0. Wilde and E. Barrett, Eds.) (Proceedings, Symposium on Current Mathemati- cal Problems in Image Science, Monterey, Cal., Nov. 1976) Western Periodicals, North Hol- lywood, 1977, pp. 10-12.