image thumbnail
from AUTO COLOR by Divakar Roy
Automatic adjustment of hue & saturation (color) of images

autocolor(input_img,output_img)
%    AUTOCOLOR
%    --> This code adjusts the hue and saturation both.Since both these
%        constitute the color of an image,thus the overall color level
%        is optimally adjusted.
%    e.g. autocolor('Sunset.jpg','Output.jpg')

function autocolor(input_img,output_img)

my_limit2=0.04;
my_limit3=-0.04;
img=imread(input_img);
if size(img,3)==1    error('AUTOCOLOR IS ONLY FOR COLORED IMAGES');
end
a= rgb2ntsc(img);
mean_adjustment=my_limit2-mean(mean(a(:,:,2)));
a(:,:,2)=a(:,:,2)+mean_adjustment*(0.596-a(:,:,2));
mean_adjustment=my_limit3-mean(mean(a(:,:,3)));
a(:,:,3)=a(:,:,3)+mean_adjustment*(0.523-a(:,:,3));
a=ntsc2rgb(a);
imwrite(uint8(a.*255),output_img);

Contact us at files@mathworks.com