Question: Digital Image Processing: Histogram Equalization having this: Need help with other functions. img = imread('image.tif'); figure(1) ; imshow(img); h = compute_histogram(img); figure(2); bar(h,1,'b'); function [
Digital Image Processing: Histogram Equalization
having this: Need help with other functions.
img = imread('image.tif'); figure(1) ; imshow(img); h = compute_histogram(img); figure(2); bar(h,1,'b');
function [ h ] = compute_histogram( img ) [n,m] = size(img); h = zeros(256); for i = 1:n for j = 1:m h(img(i,j)) = h(img(i,j))+1; end end
% normalize total_pixel = n*m; h = h./total_pixel;
end
% Matlab function that takes as input a histogram and plots it
function plot_histogram(histogram) plot((0:1:255),histogram); % plot the histogram xlabel('Intensity value'); % label x-axis xlim([0 255]); % set the range for x-axis ylim([0 max(histogram)]); % set the range for y-axis ylabel('PMF'); % label y-axis end
Write the function histogram_transform which takes as input a histogram (as returned from compute_histogram) and returns a length 256 vector T which represents the transformation function for histogram equalization. That is, when you index into T using a pixel value from an input image (offset by 1), you get the value of the pixel in the output image. Thus T is a look-up-table for the transformation. T should be computed using equation 3.3-8 (3rd edition) or equation 3-15 (4th edition) in the text. Then, write the function equalize which takes as input a grayscale image and returns the grayscale image which is the histogram equalized version of the input.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
