linear color correction with matlab

2 views (last 30 days)
how i can i fix an image by linear correction or how can i apply it without using pixel by pixel color correction
  3 Comments
huseyin kara
huseyin kara on 10 Jul 2012
after i fix the color of image with applying pixel by pixel correction, the images' shapes are not clear for example image have lots of squares. and in pixel by pixel method white which must be for example [230 230 230] became [235 243 255](rgb pixel value and this is gray) and near pixel value of white is not equal to this white. (pixel by pixel means that 3 or more pixels RGB value of an image is taken and obtaining least square matrix then apply it to whole picture.)
huseyin kara
huseyin kara on 10 Jul 2012
original image from camera(manually control contrast etc.)
after pixel by pixel correction

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 10 Jul 2012
You aren't using enough colors to span your color gamut. Three colors is simply not enough. People often use 24 because they use the industry standard x-rite Color Checker Chart. If you use only three (white, blue, and orange), then there are regions of the gamut that will get mapped to crazy, incorrect colors, as you are observing. You need to specify more standard/reference colors.

More Answers (1)

Image Analyst
Image Analyst on 10 Jul 2012
Color correction does not change the shape of anything. What you are seeing are jpeg compression artifacts. You saved the image with a very very low quality factor.
  2 Comments
huseyin kara
huseyin kara on 10 Jul 2012
i saved it png format and without saving (imshow() command) it looks like 2nd picture. my main problem is color values are increased too much such as between -40 and 350. and i try to get between 0 and 255 the image colors go wrong. Can you give me any suggestion about that.
imdir='C:\Users\infodif\Desktop\';
imfile='123.png';
im=imread([imdir, imfile]);
figure, imshow(im)
R=im(:,:,1); G=im(:,:,2); B=im(:,:,3);
r=R(:); g=G(:); b=B(:);
D=[r,g,b];
m=size(im,1); n=size(im,2);
%white pixel example
i11=im(151:160, 301:310, 1);
i12=im(151:160, 301:310, 2);
i13=im(151:160, 301:310, 3);
%blue pixel example
i21=im(251:260, 601:610, 1);
i22=im(251:260, 601:610, 2);
i23=im(251:260, 601:610, 3);
%orange pixel example
i31=im(571:580, 401:410, 1);
i32=im(571:580, 401:410, 2);
i33=im(571:580, 401:410, 3);
W=[i11(:) i12(:) i13(:); i21(:) i22(:) i23(:); i31(:) i32(:) i33(:)];
O=[230*ones(100,3); 34*ones(100,1) 41*ones(100,1) 130*ones(100,1); 232*ones(100,1) 137*ones(100,1) 32*ones(100,1)];
w=[ones(300,1), W];
t=inv(double(w')*double(w))*double(w')*double(O); % correction matrix
M=double([ones(m*n,1), D])*double(t);
Rr=(M(:,1)+30*ones(m*n,1))*(240/320)+5*ones(m*n,1);
Gg=(M(:,2)+67*ones(m*n,1))*(240/359)+0*ones(m*n,1);
Bb=(M(:,3)+36*ones(m*n,1))*(240/333)+4*ones(m*n,1);
%Rr=M(:,1)-0*ones(m*n,1);
%Gg=M(:,2)+50*ones(m*n,1);
%Bb=M(:,3)+0*ones(m*n,1);
for j=0:(n-1)
for i=1:m
rc(i,j+1)=Rr(i+j*m ,:);
gc(i,j+1)=Gg(i+j*m ,:);
bc(i,j+1)=Bb(i+j*m ,:);
end
end
RGB(:,:,1)=rc;
RGB(:,:,2)=gc;
RGB(:,:,3)=bc;
figure, imshow(uint8(RGB))
huseyin kara
huseyin kara on 10 Jul 2012
this matlab code give me almost good results but some color are wrong such as pencil's color(original is green) and cellphone's red lines(became orange)

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!