Code covered by the BSD License  

Highlights from
CONTRAST CONTROLLER

image thumbnail
from CONTRAST CONTROLLER by Divakar Roy
Contrast Adjustment of Images

contrast_controller2(input_img, low_limit, up_limit, output_img)
function contrast_controller2(input_img, low_limit, up_limit, output_img)

%CONTRAST_CONTROLLER2 : Changes the contrast of an image by the low and high
%values.
%
% Example: contrast_controller2('pic.jpg',0.008, 0.992,'pic3.jpg');
%
% NOTE:
% (1)'low_limit' and 'high_limit' are the limiters.
% (2)'low_limit'<'high_limit' and both have values ranging between 0 and 1,except 0.

img=imread(input_img);
[m1 n1 r1]=size(img);
img=double(img);
%--------------------calculation of vmin and vmax----------------------
for k=1:r1
    arr=sort(reshape(img(:,:,k),m1*n1,1));
    v_min(k)=arr(ceil(low_limit*m1*n1));
    v_max(k)=arr(ceil(up_limit*m1*n1));
end
%----------------------------------------------------------------------
if r1==3
    v_min=rgb2ntsc(v_min);
    v_max=rgb2ntsc(v_max);
end
%----------------------------------------------------------------------
img=(img-v_min(1))/(v_max(1)-v_min(1));
imwrite(uint8(img.*255),output_img);

Contact us at files@mathworks.com