function [ out_image ] = stretch( image_matrix )
% Create a function that: 
% ? realizes a histogram stretcher, 
% ? parameters of this function should be as follows: 
%     ? input: image matrix, 
%     ? output: the matrix of the stretched image, 
% ? it should work with grayscale images (check if this holds).

if (size(image_matrix,3) ~= 1)
    error 'This picture is not grayscale!'
end

min_value = double(min(min(image_matrix)));
max_value = double(max(max(image_matrix)));

out_image = uint8(255 / (max_value - min_value) * (double(image_matrix) - min_value));

end

