Code covered by the BSD License  

Highlights from
Image Enhancement

from Image Enhancement by Madhu S. Nair
Image Enhancement Range Compression Skewing slicing low pass high pass filter threshold digital nega

rgcompress(x)
%Question No:6
%RANGE COMPRESSION

function rgcompress(x)
%Range compression
f=imread(x);
f=im2double(f);
c=input('Enter the constant value, c = ');
[M,N]=size(f);
        for x = 1:M
            for y = 1:N
               g(x,y)=c*log10(1+abs(f(x,y)));
            end
        end
imshow(f), figure, imshow(g);
end

Contact us at files@mathworks.com