Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % equalize takes an image, displays it's histogram, generates a transform,
- % transforms (and outputs) the equalized image, and displays it's
- % histogram, and it's mean and Standard Deviation
- %
- % Syntax:
- % equalize(image)
- %
- % Input: an mxn grayscale image as a uint8 matrix
- %
- % Output:
- % an image of size mxn and type uint8
- %
- % History:
- % Nikolai Norona created and finished 10/22
- function equalize = equalize(image)
- M = size(image,1);
- N = size(image,2);
- %plots hist of input image
- hist = compute_histogram(image);
- plot_histogram(hist);
- figure();
- T = histogram_transform(hist);
- %round T because it needs to represent real pixel values, not doubles
- T = round(T);
- equalize = zeros([M N],'uint8');
- %iterate through old image, using T to assign values to new image
- for i = 1:M
- for j = 1:N
- equalize(i,j) = T(image(i,j)+1);
- end
- end
- %display histogram of new image
- hist2 = compute_histogram(equalize);
- plot_histogram(hist2);
- %mean and standard deviation of equalized image
- %code section written in collaboration with Jonathan Garache
- equalizedImage = double(equalize(:));
- inputImage = double(image(:));
- A = ['mean: ', num2str(mean(inputImage)), ' standard deviation: ', num2str(std(inputImage))];
- B = ['mean: ', num2str(mean(equalizedImage)), ' standard deviation: ', num2str(std(equalizedImage))];
- disp('orignal image:');
- disp(A);
- disp('new image:');
- disp(B);
- end
Advertisement
Add Comment
Please, Sign In to add comment