Image Negative Image Negative • There are a number of applications in which negative of the digital images are quite useful. Such as displaying of medical images and photographing a screen with monochrome positive film with an idea of using the resulting negatives as normal slides. • The negative of the digital image is obtained by using the transformation function s = T(r), and it is shown in Figure. • In the above figure L is the number of gray levels. The idea behind is to reverse the order from black to white so that the intensity of the output image decreases as the intensity of the input increases. Contrast Stretching During image acquisition low contrast images may be captured due to any one of the following reasons 1. Poor Illumination 2. Lack of dynamic range in the image sensor 3. Wrong setting of the lens aperture. The idea behind contrast stretching is to increase the dynamic range of gray levels in the image being processed. Figure shows a typical transformation function used for contrast stretching. Linear function • From the Figure r1 =s1, r2 = s2; r3 =s3 linearly proportional so both are same. • s-processed image r-original image this kind of transform is called linear function. Transfer function • From the Figure the location of the points (r1, s1) and (r2, s2) control the shape of the transformation function. • If r1 = r2, s1 = 0 and s2 = L – 1 the transformation becomes the thresholding function and creates a binary image. This kind of transformation is called thresholding function. Transformation function • Intermediate values of r1, s1 and r2, s2 produces various degree of spread in the gray levels at the output image, thus affecting its contrast shown in Figure Contrast stretching is obtained by setting (r1, s1) = (rmin, 0) (r2, s2) = (rmax, L–1) rmax = maximum gray level rmin = minimum gray level Thresholding Gray level Slicing • An enhancement technique in which all the gray levels in the range of interest are displayed using high values and all other gray levels are displayed using low gray levels. • In the first approach, all the gray levels in the range of interest are displayed using low values. The corresponding transformation function used is shown in Figure and this results in a binary image. • The second approach is based on transformation function shown in Figure. This transfer function brightens the desired range of gray levels but preserves the background and the gray level tonalities in the image. Bit plane slicing Histogram based Enhancement Histogram of an image represents the relative frequency of occurrence of various gray levels in the image 3000 2500 2000 1500 1000 500 0 0 50 100 150 200 19 Histogram Equalization • Histogram of a digital image is the probability of occurrence associated with the gray levels in the range 0 to 255. • Histogram can be expressed using discrete function as • Where rk is the kth gray level, nk is the number of pixels in the image with that gray level, n is the total number of pixels in the image and k = 0, 1, 2, ……. 255. • In general P(rk) gives an estimate of the probability of occurrence of gray level rk. The plot of P(rk) for all values of k is called histogram of the image and it gives a global description of the appearance of an image. Histogram Equalization • Let r be the variable representing the gray levels in the image to be enhanced. Assume that the gray levels in this image after normalization are in the range from 0 to 1. For any value of r in the original image in the internal (0, 1) the transformation is the form s = T(r) • Which produce a level s for every pixel value r in the original image. It is assumed that the transformation function given in equation satisfies the conclusion. Histogram Equalization • Image Addition • Image addition refers to addition of two or more images. It is used in image enhancement and segmentation Image Subtraction • Image subtraction plays a vital role in medical applications. The difference between two images f(x, y) and h(x, y) is expressed as g(x, y) = f(x, y) – h(x, y) Image Averaging • Consider a noisy image z(x, y) obtained by adding the noise term ɳ(x, y) to the original image f(x, y). z(x, y) = f(x, y) + ɳ(x, y) • where f(x, y) = original image ɳ(x, y) = noise • g(x, y) is a noise image. g(x, y) is obtained by adding the noise term ɳ(x, y) to the original image f(x, y). The noise term ɳ(x, y) is considered as a random phenomenon and it is correlated; so the average value of the noise results in a zero value. Illustration of Spatial filtering 7 9 11 10 50 8 9 5 6 Original Image 1/9 1 1 1 1 1 1 1 1 1 3 x 3 Averaging Mask 0 0 0 0 0 7 9 11 0 0 10 50 8 0 0 9 5 0 0 0 0 6 0 Input Image after zero padding 0 0 Movement of Spatial Mask 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 0 1/9 0 1/9 0 0 0 1/9 0 1/9 7 1/9 9 11 0 1/9 0 1/9 10 1/9 50 8 0 0 9 5 6 0 0 0 0 0 0 0 x 1/9 + 0 x 1/9 + 0 x 1/9 + 0 x 1/9 + 7 x 1/9 + 9 x 1/9 + 0 x 1/9 + 10 x 1/9 + 50 x 1/9 = 8.4 Movement of Spatial Mask (Cont..) 1/9 0 1/9 1/9 0 1/9 1/9 0 1/9 0 0 1/9 0 1/9 1/9 8.4 1/9 1/9 9 1/9 11 0 1/9 0 1/9 1/9 10 1/9 1/9 50 1/9 8 0 0 9 5 6 0 0 0 0 0 0 0 x 1/9 + 0 x 1/9 + 0 x 1/9+ 8.4 x 1/9 + 9 x 1/9 + 11 x 1/9 +10 x 1/9 +50 x 1/9 + 8 x 1/9 = 10.7 Movement of Spatial Mask (Cont..) 0 1/9 0 1/9 1/9 0 1/9 1/9 0 1/9 0 0 1/9 8.4 1/9 1/9 10.7 1/9 1/9 11 1/9 0 0 1/9 10 1/9 1/9 50 1/9 1/9 8 1/9 0 0 9 5 6 0 0 0 0 0 0 0 x 1/9 + 0 x 1/9 + 0 x 1/9+10.7 x 1/9 +11 x 1/9 + 0 x 1/9 + 50 x 1/9 + 8 x 1/9 + 0 x 1/9 = 8.8 Movement of Spatial Mask (Cont..) 1/9 0 1/9 0 1/9 0 0 0 1/9 0 1/9 8.4 1/9 1/9 10.7 1/9 8.8 1/9 0 1/9 0 1/9 10 1/9 1/9 50 1/9 8 1/9 0 1/9 0 1/9 9 1/9 5 6 0 0 0 0 0 0 0 x 1/9 + 8.4 x 1/9 +10.7 x 1/9 + 0 x 1/9 +10 x 1/9 + 50 x 1/9 + 0 x 1/9 + 9 x 1/9 + 5 x 1/9 = 10.3 Movement of Spatial Mask (Cont..) 0 0 1/9 0 1/9 1/9 8.4 1/9 0 1/9 0 0 0 0 0 1/9 1/9 10.7 1/9 8.8 0 1/9 1/9 10.3 1/9 1/9 50 1/9 8 0 1/9 1/9 9 1/9 1/9 5 1/9 6 0 0 0 0 0 8.4 x 1/9+ 10.7 x 1/9+ 8.8 x 1/9 +10.3 x 1/9 + 50 x 1/9+8 x 1/9 + 9 x 1/9 +5 x 1/9 + 6 x 1/9 = 12.9 Movement of Spatial Mask (Cont..) 0 0 0 0 0 0 1/9 8.4 1/9 1/9 10.7 1/9 1/9 8.8 1/9 0 0 1/9 10.3 1/9 1/9 12.9 1/9 1/9 8 1/9 0 0 1/9 9 1/9 1/9 5 1/9 1/9 6 1/9 0 0 0 0 0 0 10.7 x 1/9 + 8.8 x 1/9 + 0 x 1/9 + 12.9 x 1/9 + 8 x 1/9 + 0 x 1/9 + 5 x 1/9+ 6 x 1/9 + 0 x 1/9 = 5.7 Movement of Spatial Mask (Cont..) 0 0 0 0 0 8.4 1/9 10.7 1/9 8.8 1/9 0 1/9 0 1/9 10.3 1/9 1/9 12.9 1/9 5.7 1/9 0 1/9 0 1/9 9 1/9 1/9 5 1/9 6 1/9 0 1/9 0 1/9 0 1/9 0 0 0 0 0 x 1/9 + 10.3 x 1/9 +12.9 x 1/9 + 0 x 1/9 + 9 x 1/9 + 5 x 1/9 + 0 x 1/9 + 0x 1/9 + 0 x 1/9 = 4.1 Movement of Spatial Mask (Cont..) 0 0 0 0 0 0 8.4 10.7 8.8 0 1/9 0 1/9 10.3 1/9 1/9 12.9 1/9 5.7 0 1/9 0 1/9 4.1 1/9 5 1/9 6 0 1/9 0 1/9 0 1/9 0 1/9 0 0 10.3 x 1/9 +12.9 x 1/9 + 5.7x 1/9 + 4.1 x 1/9 + 5 x 1/9 + 6 x 1/9 + 0 x 1/9 + 0 x 1/9 + 0 x 1/9 = 4.6 Movement of Spatial Mask (Cont..) 0 0 0 0 0 0 8.4 10.7 8.8 0 0 1/9 10.3 1/9 12.9 1/9 1/9 5.7 1/9 0 0 1/9 4.1 1/9 4.6 1/9 6 1/9 0 0 1/9 0 1/9 0 1/9 0 1/9 0 12.9 x 1/9 + 5.7 x 1/9 + 0 x 1/9 + 4.6 x 1/9 + 6 x 1/9+ 0 x 1/9 + 0 x 1/9 + 0 x 1/9 + 0 x 1/9 = 3.2 Movement of Spatial Mask (Cont..) 0 0 0 0 0 0 8.4 10.7 8.8 0 0 10.3 12.9 5.7 0 0 4.1 4.6 3.2 0 0 0 0 0 0 Result of Averaging filter 7 9 11 8.4 10.7 10 50 8 10.3 12.9 5.7 9 5 6 4.1 4.6 3.2 Original Image 8.8 Image after Spatial Averaging Smoothing Filters • Smoothing filters are used for blurring and noise reduction. Noise reduction can be accomplished by blurring with a linear filter by a nonlinear filter. Two types of smoothing filters are spatial LPF and Median Filter. • Low Pass Spatial Filters • The Low Pass Spatial Filters are used to reduce the noise such as bridging of small gaps in the lines or curves in a given image. The spectrum of the spatial Low Pass Filter is shown in Figure 3 X3 Low pass spatial mask Median Filter Sharpening Filters • The principal objective of sharpening Filter is to highlight fi ne details and enhance edge (sharp) details. Sharpening Filters are divided into three types. • They are • Spatial HPF, • High Boost Filter and • Derivative Filter. High Pass Spatial Filter • The High Pass Spatial Filter attenuates low frequency components heavily and pass the high frequency components. This results in an image with sharp details such as edges and high contrast. Additionally, HPF can provide more visible details that are obscured, hazy and of poor focus in the original image. Spatial HPF response is shown in Figure. The center of the mask has a positive value and all its neighbour coefficients have negative values. The center pixel has the gray level of 200 and the remaining pixels have gray level of 10, then the corresponding response of the mask is given as