Teaching     Home

MIT's IAP, 1999
Fundamentals of Image Processing
9.99, 3 credits
Jan 4-8, 10:00-12:30, E10-013

Image Formation
  • pinhole cameras
  • perspective/orthographic projection
  • lenses
  • CCD
Pointwise Operations
  • brightness/contrast
  • gamma correction
  • quantization/threshold
  • histogram equalization
Basics
  • linear time-invariant systems
  • convolution
  • Fourier transform
  • sampling theory
Linear Filtering
  • differentiation
  • bandpass
  • filter design
  • multi-scale transforms
Applications
  • noise removal
  • image enhancement

Exercise 1. Given an image, compute the lookup table (LUT) that will equalize its histogram. To view your results, either apply the new LUT directly to the image, or simply change the linear LUT using the matlab command 'colormap'.



Einstein equalized and down-sampled by a factor of two.
% LOAD IMAGE
im	= imread( 'al.jpg' );
im	= double( im );

% COMPUTE NEW LOOKUP TABLE
minim	= min( im(:) );
maxim	= max( im(:) );
inc	= (maxim-minim)/63;
X	= [minim : inc : maxim];
N	= hist( im(:), X );
T	= sum( N );
N2	= cumsum( N ) / T;
X2	= [minim : (maxim-minim)/255 : maxim];
N2	= interp1( X, N2, X2, '*linear' );
lut	= N2' * [1 1 1];  % NEW COLORMAP
imagesc( im, [0 255] ); 
axis image off; 
colormap(lut);

%%% LOOK AT ALL THE PIECES

% APPLY NEW LOOKUP TABLE TO IMAGE - DESTRUCTIVELY MODIFY IMAGE
[ydim,xdim] 	= size(im);
im_eq		= 255*interp1( X2, N2, im(:), '*linear' );
im_eq		= reshape( im_eq, ydim, xdim ); 

figure(1); 
subplot( 2,3,1 );
imagesc( im, [0 255] ); axis image off; colormap gray;
title( 'Einstein' );
colormap gray; 

subplot( 2,3,2 );
hist( im(:), 16 ); axis( [0 256 0 15000] ); axis square;

subplot( 2,3,3 );
plot( N2 ); axis( [0 255 0 1] ); axis square; 
title( 'Lookup Table' );

subplot( 2,3,4 );
imagesc( im_eq, [0 255] ); axis image off; colormap gray;
title( 'Einstein Equalized' );
colormap gray; 

subplot( 2,3,5 );
hist( im_eq(:), 16 ); axis( [0 256 0 15000] ); axis square;

Exercise 2. Starting with an NxN image, use the following bicubic interpolation filter to create a 2Nx2N image. Compare the results with nearest neighbor interpolation.
     0.00391 0.0 -0.03516 -0.06250 -0.03516 0.0  0.00391
     0.00000 0.0  0.00000  0.00000  0.00000 0.0  0.00000
    -0.03516 0.0  0.31641  0.56250  0.31641 0.0 -0.03516
    -0.06250 0.0  0.56250  1.00000  0.56250 0.0 -0.06250
    -0.03516 0.0  0.31641  0.56250  0.31641 0.0 -0.03516
     0.00000 0.0  0.00000  0.00000  0.00000 0.0  0.00000
     0.00391 0.0 -0.03516 -0.06250 -0.03516 0.0  0.00391
%%% UPSAMPLE BY 2x
im              = imread( 'al.jpg' );
im              = double( im );
[ydim,xdim]     = size(im);
im2             = zeros( 2*ydim, 2*xdim );
im2(1:2:2*ydim, 1:2:2*xdim) = im;
im2             = conv2( im2, filt, 'same' );

Exercise 3. Below is an image from a surveillance camera that has, to our disfortune, been corrupted so that the license plate is illegible. Can you uncover the license plate number?






Solution, contrast enhanced and up-sampled by a factor of 2
im	= imread( 'license.jpg' );
im	= double( im );

IM	= fftshift( fft2(fftshift(im)) );
midwx	= 128;
midwy	= 81;
sz	= 3;
for i = 2 : 75
	IM( midwy-i-sz:midwy-i+sz, midwx-i-sz:midwx-i+sz ) = 0;
	IM( midwy+i-sz:midwy+i+sz, midwx+i-sz:midwx+i+sz ) = 0;
end

im2	= fftshift( ifft2(fftshift(IM)) );
im2	= real( im2 );
im2	= im2 - min(im2(:));
im2	= im2 / max(im2(:));
imagesc( im2, [0 1] ); axis image off;
colormap gray;

Teaching     Home