% sample.m
%
% Shows an example of median filtering and histogram equalization.

I = imread('trees.tif');
I2 = imnoise(I,'gaussian',0,0.20);

% Try image I/O
imwrite(I2, 'trees_var020.tif');
I3 = imread('trees_var020.tif');

% Median filtering
m = medfilt2(I3);
med = medfilt2(m);

% Histogram equalization
J = histeq(med);

% Display results
subplot(1,4,1), subimage(I); 
subplot(1,4,2), subimage(I3);
subplot(1,4,3), subimage(med);
subplot(1,4,4), subimage(J);

% Another way to show results
% imshow(I), figure, imshow(I3), figure, imshow(med), figure, imshow(J);



 
