Intensity Transformations Examples Colorado School of Mines Image and Multidimensional Signal Processing 1 Example 1 – Dehazing • Images of outdoor scenes are often degraded by haze (due to fog, dust, etc). Light is attenuated by its passage through the atmosphere, and additional unwanted scattered light is added. • We want to enhance the images to remove the effect of the haze. Raw Two aerial images with a lot of haze Colorado School of Mines Images are courtesy of Microsoft Bing Maps group Image and Multidimensional Signal Processing 2 Example 1 – Dehazing (continued) • Look at input histograms of images “haze1.tif” and “haze2.tif”. Iin = imread('haze1.tif'); % Look at input histograms. I = imresize(Iin, 0.2); figure, imshow(I), title('Input'); Rx = imhist(I(:,:,1),256); Gx = imhist(I(:,:,2),256); Bx = imhist(I(:,:,3),256); figure, plot(0:255, Rx, 'r', 0:255, Gx, 'g', 0:255, Bx, 'b'); title('Input histograms'); • Let’s assume that the pixels in the degraded image that have the lowest values (in each color band) actually should be pure black, and the pixels that have the highest values (in each color band) are actually should be pure white. Colorado School of Mines Image and Multidimensional Signal Processing 3 Example 1 – Dehazing (continued) • A simple de-hazing algorithm is to take a color image, and for each band (red, green, blue), stretch its values to occupy the full range (0 to 255), such that 1% of data at the extreme ends is saturated at the low and high values (see Matlab’s “imadjust”). Then put the bands back together into an RGB image. Colorado School of Mines Image and Multidimensional Signal Processing 4 Example 2 – histogram equalization • Manual histogram equalization • Read image “Fig0309(a).tif” • Reduce range of gray levels to 0..15 Colorado School of Mines Image and Multidimensional Signal Processing 5 Example 2 - histogram equalization (continued) clear all close all I = imread('Fig0309(a).tif'); I = I/16; % Reduce gray levels from 0..255 to 0..15 imshow(I,[]); [H,X] = imhist(I); % Get histogram disp('Initial histogram:'); disp([X(1:16) H(1:16)]); % Display entries for 0..15 Colorado School of Mines Image and Multidimensional Signal Processing Initial histogram: 0 875 1 0 2 0 3 2855 4 7727 5 9021 6 6458 7 8672 8 11475 9 19487 10 39222 11 50467 12 77795 13 142872 14 117743 15 65031 6 Example 2 - histogram equalization (continued) • Using an Excel spreadsheet and following the examples in Lecture 5, do the following: – Compute the transformation function s = T(r) that will equalize the histogram. – Estimate the histogram of the output (equalized) image. Colorado School of Mines Image and Multidimensional Signal Processing 7