%
% Lady.m
%
%  This is homework 3, problem 2, ECE 5273, Spring 2015.
%
%  jph 21 April 2002
%  jph 21 February 2005: update histogram call; use 'hist'.
%  jph 21 February 2011: this is now HW 3.
%  jph  8 February 2015: Call subroutines to read image and stretch.
%

xsize = 256;

%
% read lady.bin, transpose, display, and print
%
x = ReadBin('lady.bin',xsize);
figure(1);colormap(gray(256));
image(x);axis('image');
title('Original Lady Image','FontSize',12);
print -deps MLadyCrop.eps;
print -dpdf MLady.pdf;

%
% Compute, plot, and print histogram of original image
%
histx = sum(hist(x,0:255)');
figure(2);
bar(histx);
title('Histogram of Original Lady Image','FontSize',12);
print -deps MOrigHistCrop.eps;
print -dpdf MOrigHist.pdf;

%
% Perform full-scale contrast stretch, display and print
%
y = stretch(x);
figure(3);colormap(gray(256));
image(y);axis('image');
title('Result after full-scale stretch','FontSize',12);
print -deps MNewLadyCrop.eps
print -dpdf MNewLady.pdf

%
% Compute new histogram, plot and print.
%
histy = sum(hist(y,0:255)');
figure(4);
bar(histy);
title('Histogram of New Lady Image','FontSize',12);
print -deps MFinalHistCrop.eps
print -dpdf MFinalHist.pdf
