% % SIO135/236 Lab 5, Spring 2009 % clear % % Problem 1) Image contrast enhancement % % % read and display the thermal infrared band % ir = fread( fopen( 'band6c.raw', 'r'), [1500 1500], '*uint8')'; figure(1),colormap('gray') imshow(ir) title( 'Original Data' ); % % linear contrast stretch (set display limits in imshow) % min_pixel = min( min( ir ) ); max_pixel = max( max( ir ) ); figure(2),colormap('gray'), title( 'Linear Stretch' ); % % histogram equallization using built-in matlab function histeq() % figure(3),colormap('gray') title( 'Histogram Equalization' ); % % look at the histogram for each % figure(4),colormap('gray'); subplot(2,1,1), imhist(ir); % % Problem 2) % % % read in 3 bands % % % look at the RGB image with contrast enhancement % rgb = cat(3, rd, gr, bl ); figure(5), imshow(rgb), title( 'RGB Image' ); % % enhance the contrast in each band, and look at the histogram for each % figure(6); subplot(3,2,1), imhist(rd), title('Red'); rdeq = histeq(rd); subplot(3,2,2), imhist(rdeq), title('Red Equalized'); % % combine the equalized bands and have a look % figure(7); rgbeq = cat( 3, rdeq, greq, bleq ); imshow(rgbeq), title( 'RGB Equalized' ); % % Problem 3) image enhancement through filtering % % % load & show the un-touched image % bl = fread( fopen( 'band1c.raw', 'r'), [1500 1500], '*uint8')'; figure(8),colormap('gray'), imagesc( bl ), title('Original'); % % apply a smoothing filter % smoothfilt=[1/9, 1/9, 1/9; 1/9, 1/9, 1/9; 1/9, 1/9, 1/9] bl_smooth = filter2( smoothfilt, bl ); figure(9),colormap('gray'), imagesc( bl_smooth ), title('Smoothed'); % % apply a sharpening filter % % % illuminate from the northwest % % % Problem 4) compute the vegetation index % % % read in apropriate bands and convert them to doubles. % red = double(fread( fopen( 'band3c.raw', 'r'), [1500 1500], '*uint8')'); ir = double(fread( fopen( 'band4c.raw', 'r'), [1500 1500], '*uint8')'); % % compute the vegetation index band transformation and display with imagesc %