Virtual Makeup

I was just sitting at my home and whiling away the time during my summer holidays and then I thought why not try something with python.

Why Python? It is simply because I just love python for its neat flawless syntax.

I tried doing color transfer onto an image, i.e. changing the color of an image without affecting the texture present in the image. For doing this I had to use LAB color space.

LAB color space is specially designed to measure colors in the same way human brain interprets them. So, I found this color space to be very apt for this project. I could just change the L, A and B values of each pixel by a constant value and get done with the color transfer.

For more info on LAB color space.

ALGORITHM : 

Let ( L1, A1, B1 ) = mean of (L ), mean of(A ), mean of (B ) of all the pixels where color has to be changed and let (L2, A2, B2) be the LAB values of the final color to which the image has to be changed. Then for each pixel of the image,

L has to be increased by (L2 – L1)

A has to be increased by (A2 – A1)

B has to be increased by (B2 – B1)

So, essentially I m just changing the mean of each component of the LAB color space of the image to the target color’s LAB value. By doing so our eyes will perceive it in the same way as it did with that target color.

So, this will change the color of the image without affecting the texture. Now I did this same color transfer with an image of a face, where i applied the color transfer for just the cheeks of the face.

Then, I added gaussian blur from opencv python module to smoothen the edges of the region where color transfer was done. The final result obtained is shown below.

Before

Input1

After

output

 

Then, I tried the same for applying lipstick and nail polish.

The source code for the project can be found here.

 

3 thoughts on “Virtual Makeup

    1. Your blog is very fascinating to me.
      I’d like to know about the program method that integrate virtual makeup function to the website.
      Thanks

      Like

  1. It is just very large along with you to offer overtly what precisely lots of people would’ve publicized a great e-book to finish up generating some money with regards to unique conclude, primarily provided that one could include experimented with the item when you required.

    Like

Leave a comment