| Virtual Makeup | The beauty vs RGB! |
The theory:
A computer image is made with pixels. All pixels are coded in RGB, e.b. R for
red, G for green and B for blue. With a mix of all those 3 colors, you can
produce any colors. By example, 100% Red + 100% Green = Pure Yellow . In windows,
all RGB colors are coded in octals [0-255], where 255 is 100%. With this
information, a programmer can make a software to change anything in a picture.
This is an example:
![]() |
![]() |
|
Original |
After processing |
The color of the eyes:
Before you can color the eyes, you just have to define the work zone. For this picture of Avril Lavigne, I defined this zone:
X > 145 < 291 , Y > 250 < 270 , X < 168 >212
Step 2, Detect the color to change:
Avril have blue-green eyes. This color have exactly the same level of blue and
green. The formula to detect this color is:
Red < 82, Green > 16, Blue > 16
Step 3, Change the color
I tried different kinds of colors and levels but the best, the most natural was 13.7 % more of blue. This is the technique:
If Blue < 255-35 Then Blue = Blue + 35 ( 255-35 is the maximum of blue level )
To keep the darkness of the original eyes, add:
If Red > 35 Then Red = Red - 35
If Green > 35 Then Red = Red - 35
You can also change any colors of your choice, by example you can boost only the green ( to make green eyes.)
This is an example of programmation for Delphi:
( first define 2 Images Box (Image1 & Image2) )
Procedure
TForm1.Button1Click(Sender: TObject);
var
c:LongInt;
color:longint;
red,green,blue:Byte;
x,y:integer;
bobo:Boolean;
begin
for y:=0 to my do // my is the height of Image1
begin
for x:=0 to mx do // mx is
the width of Image1
begin
c:=Image1.Canvas.Pixels[x, y]; //
C = The current pixel
blue := GetBValue(c);
green := GetGValue(c);
red := GetRValue(c);
bobo:=False;
if x in [168..212] then bobo:=True; //
exclusion zone
if (x>145) and (x<291) and
(y>250) and (y<270) and (bobo=False) then // in the eyes ?
if (blue>16) and (green>16) and (red<82)
then // blue-green color ?
begin
cc:=35; // 13.7
%
if blue<=255-cc then blue:=blue+cc;
// the blue color is boosted
//if green>=cc then green:=green-cc;
// add if you want to keep the darkness of the original
//if red>=cc then red:=red-cc; //
'' '' ''
end;
color:=RGB(red,green,blue); //
Color = the new color
Image2.Canvas.Pixels[x,y]:=color; //
we put the pixel
end;
end;
end;
For more informations: hostmaster@aiglonsoft.com