You are on page 1of 4

LAB 7: Basic Image Functions and Histogram

Submitted in fulfillment of the requirements for the


ENGINEERING DEGREE FROM THE LEBANESE UNIVERSITY FACULTY OF
ENGINEERING – BRANCH Major: Electrical Engineering

To: Dr. Antoine ASSAF


By: Christina HACHEM
_____________________________________________
Problem 1: Local Histogram Equalization

function g = localhisteq(f, m, n)

if nargin == 1

m = 3; n = 3;

elseif nargin == 2

n = m;

end

if (mod(m,2) == 0 || mod(n,2) == 0)

error('The dimensions of the neighborhood should be odd')

end

f = im2uint8(f);

[L T] = size(f);

f = padarray(f, [m n], 'symmetric', 'both');

x1 = 0;

for x = (m + 1)/2 + 1 : L + (m + 1)/2

x1 = x1 + 1;

y1 = 0;

for y = (n + 1)/2 + 1 : T + (n + 1)/2

y1 = y1 + 1;

subimage = f(x:x + m - 1, y:y + n - 1);

h = histeq(subimage);

g(x1, y1) = h((m + 1)/2, (n + 1)/2);

end

end
Problem 2: Comparing Global and Local Histogram Equalization.

(a)

>> f = imread('Fig1.tif');

>> f = imread('Fig1.tif');

>>figure1=figure

>>hloc3=localhisteq(f,3,3);

>>hloc7=localhisteq(f,7,7);

>> subplot(2,2,1);

>> imshow(f);

>> title('Original Image');

>>subplot(2,2,2);

>>imshow(hloc3);

>>title('3x3 Local Equalization');

>>subplot(2,2,3);

>> imshow(hloc7);

>> title('7x7 Local Equalization');

(b)

>> h = histeq(f,64);

>>subplot(2,2,4);

>>imshow(h);

>>title('General Histogram Equalization');

>> print(figure1);
(a) By analyzing the processed images, the main difference between doing local equalization using 3x3
window or 7x7 window is that, as the size of the local window increases, the distortion increases (seen
as a blurring in the 7x7 Local Equalization figure). The reason is the intensity mappings of the histogram
with a larger area.

(b) Global equalization could not bring out the details embedded in the black squares within the image
because they had little effect on the shape of the global transformation function (the cumulative
distribution function).

You might also like