obr1=

f[{r_,g_,b_}]:=If[r>g+b,{r,g,b},z=(r+g+b)/3;{z,z,z}]

obr2=ImageApply[f,obr1]

g[x_]:=1-x;

obr3=ImageApply[g,obr1]