I intended to choose one point of the image and compare other points' RGB values with this point's, and then change the similar points' colors, but I failed. Following is my code:
function exchangecolor()
I1=imread('F:\28.jpg');
I2=imread('F:\29.jpg');
[m1,n1,x1]=(size(I1));
[m2,n2,x2]=size(I2); //[399,400,3]=size(I1)=size(I2)
r1=I1(200,200,1);
r2=I2(200,200,1);
g1=I1(200,200,2);
g2=I2(200,200,2);
b1=I1(200,200,3);
b2=I2(200,200,3);
for i=1:m1
for j=1:n1
if abs(I1(i,j,1)-r1)<=10
if abs(I1(i,j,2)-g1)<=10
if abs(I1(i,j,3)-b1)<=10
I1(i,j,1)=r2;
I1(i,j,2)=g2;
I1(i,j,3)=b2;
end
end
end
end
end
imwrite(I1,'F:\89.jpg','jpg');