Download presentation
Presentation is loading. Please wait.
1
The Point Processing of Images
2
Basic image processing operations
In this lecture we study techniques for resolution enhancement and reduction, and adjusting color distribution (histogram and LUT operations). We operate with 8 bpp gray-scale images each constrained to the range [0, 255], unless otherwise noted. Changing resolution A reduced resolution version of a given image is sometimes needed for a preview purpose, for example. A preview image (or thumbnail) must be small enough to allow fast access but also with sufficient quality so that the original image is still recognizable. A smaller resolution copy is also needed if the image is embedded into another application (or printed) using smaller size as the full resolution would allow Resolution reduction is formally defined as follows: given an image of NXM pixels, generate an image of size N/c X M/c pixels (where c is a zooming factor) so that the visual content of the image is preserved as well as possible. There are two alternative strategies
3
Sub sampling Averaging
In both cases, the input image is divided into blocks of c x c pixels. For each block, one representative pixel is generated to the output image (Figure 2.1). In sub sampling, any of the input pixels are chosen, e.g. the upper leftmost pixel in the block. In averaging, the pixel depends on the values of all input pixels in the block. It could be chosen as the average, weighted average, or the median of the pixels. Averaging results in smoother image whereas sub sampling preserves more details. Figure 2.1
4
I = imread('liftingbody.png');
fun=inline('mean2(x)'); I2 = blkproc(I,[8 8],fun); imtool(I),imtool(I2,[])
5
A straightforward method simply takes copies of the input pixel but this results in a jagged (blocky) image where the pixels are clearly visible. A more sophisticated method known as bilinear interpolation generates the unknown pixel values by taking the linear combination of the four nearest known pixel values (Figure 2.2). The value of a pixel xi,j at the location (i,j) can be calculated as: where a, b, c, d are the nearest known pixel values to x; i and j define the relative distance from a to x (varying from 0 to 1). The result is a smoother image compared to straightforward copying of a single pixel value. Examples of resolution reduction and resolution increasing by interpolation is illustrated in Figures 2.3 and 2.4. Figure 2.2: Bilinear interpolation of pixel x using the four known pixels a, b, c, d. I = imread('pout.tif'); x=imresize(I,[20 30]); figure,imshow(I), imshow(x)
6
Figure 2.3: Example of resolution reduction 384256 4832: original image (left), resolution reduced by averaging (middle), and by sub sampling (right). Figure 2.4: Bilinear interpolation using two 4832 images obtained using averaging (top), sub sampling (below). Interpolated images: original (left), 9264 (middle), 192128 (right).
7
Point Processing of Images
In a digital image, point = pixel. Point processing transforms a pixel’s value as function of its value alone; it does not depend on the values of the pixel’s neighbors. 11/24/2018
8
Spatial Domain Procedures that operate directly on pixels. where (x,y)
Origin x (x,y) Image f(x,y) y T is an operator on f defined over some neighborhood of (x,y)
9
Example 1: Fixed Intensity Transformation
A 4x4, 4bits/pixel image passes through an intensity transformation 1 round(0.0667) = 0; 3 round(0.6) = 1; 6 round(2.4) = 2; 7 round(3.2667) = 3; 8 round(4.2667) = 4; 9 round(5.4) =5; 10 round(6.6667) = 7; 11 round(8.0667) = 8; The resulting image is:
10
Example2: A 4x4, 4bits/pixel image passes through a point-wise intensity transformation given by
where α and β are unknown parameters. Only a few pixels are available in the input and the output images, as shown below. 3 15 ? 1 5 11 8 ? T(r) r S
11
Constant addition and negation
The simplest form of global transform are constant addition (also known as DC-shift) and negation . The former is used to enhance dark images. The latter can be used for displaying medical images and photographs on screen with monochrome positive film with the idea of using the resulting negatives as normal slides. Constant addition: f(x) = x + c (2.3) Negation: f(x) = c - x (2.4) % add 50 to every pixel I = imread('rice.png'); Iplus50 = imadd(I,50); imview(I), imview(Iplus50) % Subtract a constant value from the rice image: Iq = imsubtract(I,50); imview(I), imview(Iq)
12
Negative Transformation
An image with gray level in the range [0, L -1] where L = 2n ; n = 1, 2… ( Number of bits/ pixel ) Negative transformation : Reversing the intensity levels of an image. Suitable for enhancing white or gray detail embedded in dark regions of an image, especially when the black area dominant in size. f(x)= (2n -1) –x
13
Point Processing of Images
Brightness and contrast adjustment Gamma correction Histogram equalization
14
Point Processing - gamma - brightness original + brightness + gamma
histogram mod - contrast original + contrast histogram EQ
15
Point Ops via Functional Mappings
, point operator J Image: Input Output I(r,c) function, f J(r,c) Pixel: The transformation of image I into image J is accomplished by replacing each input intensity, g, with a specific output intensity, k, at every location (r,c) where I(r,c) = g. The rule that associates k with g is usually specified with a function, f, so that f (g) = k. 11/24/2018
16
Basic Transformation Negative: Log: Inverse Log: Power-law:
17
Point Ops via Functional Mappings
One-band Image Either all 3 bands are mapped through the same function, f, or … Three-band Image … each band is mapped through a separate func-tion, fb. 11/24/2018
18
Point Operations using Look-up Tables
… then the LUT that implements f is a 256x1 array whose (g +1)th value is k = f (g). A look-up table (LUT) implements a functional mapping. To remap a 1-band image, I, to J :
19
Point Operations using Look-up Tables
If I is 3-band, then each band is mapped separately using the same LUT for each band or each band is mapped using different LUTs – one for each band.
20
Point Operations = Look-up Table Ops
index value ... 101 102 103 104 105 106 64 68 69 70 71 E.g.: 255 output value 127 127 255 input value input output 11/24/2018
21
Look-Up Tables a pixel with this value is mapped to this value
cell index contents . input output a pixel with this value is mapped to this value 11/24/2018
22
How to Generate a Look-Up Table
For example: Or in Matlab: a = 2; x = 0:255; LUT = 255 ./ (1+exp(-a*(x-127)/32)); This is just one example. 11/24/2018
23
Point Processes: Increase Brightness
127 255 transform mapping 11/24/2018
24
Point Processes: Decrease Brightness
127 255 255-g transform mapping 11/24/2018
25
Point Processes: Increase Contrast
127 255 transform mapping 11/24/2018
26
Point Processes: Decrease Contrast
127 255 transform mapping 11/24/2018
27
Point Processes: Contrast Stretch
MJ 127 255 mJ mI MI transform mapping I = imread('pout.tif'); J = imadjust(I,stretchlim(I),[]); imview(I), imview(J) 11/24/2018
28
Example: Full-Scale Contrast Stretch
Full-scale contrast stretch of a 4x4, 4bits/pixel image Find 4 round(0) = 0; 6 round(4.29) = 4; 7 round(6.43) = 6; 8 round(8.57) = 9; 9 round(10.71) = 11; 10 round(12.86) = 13; 11 round(15) = 15; The resulting image is:
29
General Idea: Make Best Use of the Dynamic Range
Piecewise- Linear Transformation Functions Advantage: The form of piecewise functions can be arbitrarily complex Disadvantage: Their specification requires considerably more user input General Idea: Make Best Use of the Dynamic Range
30
Contrast Stretch General form:
Special case Full-scale contrast stretch: Typically used:
31
Point Processes: Increased Gamma
127 255 transform mapping 11/24/2018
32
Point Processes: Decreased Gamma
127 255 m M transform mapping 11/24/2018
33
Highlighting a specific range of gray levels in an image
Gray-level slicing Highlighting a specific range of gray levels in an image Display a high value of all gray levels in the range of interest and a low value for all other gray levels (a) transformation highlights range [A,B] of gray level and reduces all others to a constant level (b) transformation highlights range [A,B] but preserves all other levels a b A B A B a b
34
Image Histogram 1 2 4 5 image histogram
35
Example: a 4x4, 4bits/pixel image
36
Normalized Histogram dividing each of histogram at gray level rk by the total number of pixels in the image, n For k = 0,1,…,L-1 p(rk) gives an estimate of the probability of occurrence of gray level rk The sum of all components of a normalized histogram is equal to 1
37
Dark image Components of histogram are concentrated on the low side of the gray scale.
Bright image Components of histogram are concentrated on the high side of the gray scale.
38
The Histogram of a Grayscale Image
black marks pixels with intensity g lower RHC: number of pixels with intensity g 16-level (4-bit) image
39
The Histogram of a Grayscale Image
Black marks pixels with intensity g Plot of histogram: number of pixels with intensity g
40
Algorithm1 : Calculation of an Image Histogram
create an array histogram with 2b elements for all grey levels ,I, do histogram[i]=0; end for for all pixel coordinates, x,y,do increment histogram[f(x,y)] by 1 End for
41
Single -Band Histogram Calculator in Matlab
% Sample matlab code: Function[f]= histogram(imgname) img=imread(imgname); figure; imshow(img); [M,N]=size(img); %computing histogram: H=zeros(256,1); for (i=1:M) for (j=1:N) f=double(img(i,j))+1; H(f)=H(f)+1; end; figure; bar(H); Matlab: imhist( ): can compute and display histograms
42
Multi-Band Histogram Calculator in Matlab
function h=histogram(I) [R C B]=size(I); % allocate the histogram h=zeros(256,1,B); % range through the intensity values for g=0:255 h(g+1,1,:) = sum(sum(I==g)); % accumulate end return;
43
Multi-Band Histogram Calculator in Matlab
function h=histogram(I) [R C B]=size(I); % allocate the histogram h=zeros(256,1,B); % range through the intensity values for g=0:255 h(g+1,1,:) = sum(sum(I==g)); % accumulate end return; Loop through all intensity levels (0-255) Tag the elements that have value g. The result is an RxCxB logical array that has a 1 wherever I(r,c,b) = g and 0’s everywhere else. Compute the number of ones in each band of the image for intensity g. Store that value in the 256x1xB histogram at h(g+1,1,b). sum(sum(I==g)) computes one number for each band in the image. If B==3, then h(g+1,1,:) contains 3 numbers: the number of pixels in bands 1, 2, & 3 that have intensity g.
44
The Histogram of a Grayscale Image
Let I be a 1-band (grayscale) image. I(r,c) is an 8-bit integer between 0 and 255. Histogram, hI, of I: a 256-element array, hI hI (g), for g = 1, 2, 3, …, 256, is an integer hI (g) = number of pixels in I that have value g-1.
45
The Histogram of a Grayscale Image
Luminosity
46
The Histogram of a Color Image
If I is a 3-band image (truecolor, 24-bit) then I(r,c,b) is an integer between 0 and 255. Either I has 3 histograms: hR(g+1) = # of pixels in I(:,:,1) with intensity value g hG(g+1) = # of pixels in I(:,:,2) with intensity value g hB(g+1) = # of pixels in I(:,:,3) with intensity value g or 1 vector-valued histogram, h(g,1,b) where h(g+1,1,1) = # of pixels in I with red intensity value g h(g+1,1,2) = # of pixels in I with green intensity value g h(g+1,1,3) = # of pixels in I with blue intensity value g
47
The Histogram of a Color Image
Luminosity There is one histo-gram per color band R, G, & B. Luminosity histogram is from 1 band = (R+G+B)/3
48
Value or Luminance Histograms
The value histogram of a 3-band (truecolor) image, I, is the histogram of the value image, Where R, G, and B are the red, green, and blue bands of I. The luminance histogram of I is the histogram of the luminance image,
49
Cumulative Histogram It records the cumulative frequency distribution of grey levels in an image. The cumulative frequency of a grey level, i , is the number of times that a grey level less than or equal to i occurs in an image. Cumulative frequencies, ci are computed from the histogram counts, hi , using The normalized value of cumulative frequency can be obtained by dividing the above equation by n
50
Example 2 3 4 5 Grey level i 1 2 3 4 5 6 7 8 9 ni cj 11 15 16 6/16
1 2 3 4 5 6 7 8 9 ni cj 11 15 16 6/16 5/16 4/16 1/16 11/16 15/16
51
Histogram Equalization
Sometimes the histogram of an image contains mostly dark pixels; this is the case of an insufficiently exposed photograph. The image can be enhanced by constant addition but histogram equalization is generally more efficient technique for this purpose The idea of the method is to spread the histogram as evenly as possible over the full intensity scale. This is done by calculating cumulative sums of the pixel samples for each gray level value x in the histogram. The sum implies the number of gray levels that should be allocated to the range [0, r], and is proportional to the cumulative frequency C(r), and to the total number of gray levels L
52
Histogram Equalization
Where B= Number of bit/ pixel ( B=1,2,………,8) r= grey levels of the input image and S= grey levels of the output image
53
Histogram Equalization Example
Intensity Number of pixels Number of pixels
54
Histogram Equalization Example
55
Histogram Equalization Example
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the intensity distribution shown in following table. Get the histogram equalization transformation function and give the ps(sk) for each sk.
56
input histogram equalized histogram
57
Example A 4x4, 4bits/pixel image
First try: full-scale contrast stretch 2 round(0) = 0; 3 round(1.67) = 2; 8 round(10.00) = 10; 9 round(11.67) = 12; 10 round(13.33) = 13; 11 round(15) = 15; The resulting image is:
58
Example: Histogram Change
full-scale contrast stretch original big gap
59
Cumulative Histogram H(k) Q(k)
60
Intermediate Image intermediate image original
61
Full-Scale Contrast Stretch of Intermediate Image
2 round(0) = 0; 6 round(4.29) = 4; 9 round(7.50) = 8; 12 round(10.71) = 11; 14 round(12.86) = 13; 16 round(15) = 15; final result: histogram equalized image
62
direct full-scale contrast stretch
Histogram Comparison original direct full-scale contrast stretch histogram-equalized more equalized
63
Given an image as below, derive the intensity mapping that will as best
as possible equalize the image histogram. The image histogram is as shown on the right. There are 8 possible grey scale levels from 0 to 7. 4 3 5
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.