The Art of Filter Making

Debalina De
DSC CGC
Published in
6 min readMar 26, 2020

Let's be honest, we all are obsessed with filters. Be it Snapchat or Instagram, we all find ourselves voluntarily using those quirky face filters or background effects. Filters not only make the image look good but it also improves the quality of the image. I, myself is a huge fan of Instagram and its amazing filters. So, being a Computer Science student, I began my quest to discover the most convenient and efficient techniques for creating one's very own image filter. In this blog, I have tried to give a vivid demonstration of two types of filters: Background filters & Face filters and ways of how one can implement these quite easily. Hence without any further adieu, let's get started.

Before getting into the building phase, lets tick all the requirements.

Prerequisites:

  • Acquaintance to programming and its paradigm: Since we will be creating our very own customizable filters, we need to have a fair understanding of the backend functionalities. Usually, Python programming language is used for filter making because of its wide collection of packages in libraries. These contain a lot of predefined functions, hence are simpler to use. To try out Python programming, click here.
  • Compatible OS and good Memory space: Filter Making comes under the radar of Computer Vision which is a subcategory of Deep Learning. When we start dealing with ML/DP we give a lot of stress on datasets and libraries and of course the hyperparameters. When you are building your face filter, your Operating System should be 64 bits, Processor should be intel i5 generation(although i3 will also work) and RAM at least 4GB. You also need to install the latest version of Python and some of its libraries.
Basic Python libraries required for creating filters
  • A creative mind: This is one of the most underrated segments which plays a very crucial role in building the base of your filter making. The more creative you would be, the more appealing the results would be. So, keep finding art in tech.
Picture Courtesy: www.Medium.com

Filter making: To add effects around or on the face

Face filters have all the hype around social media. Before dealing with a face filter, one should understand the concept of face detection using OpenCV. How do we detect whether its a human or an ostrich? We look for unique features for each one of them, compare them with any prior knowledge and come to a solution. This is exactly what we do in face detection as well. We first train the machine with various data models to mark the unique features of a face like eyes,eye-spacing, nose, mouth, etc.

Pyramidal representation of an image for face detection

In technical terms, we compute the pyramidal representation of that image which is a pyramid of multi-scaled (maybe Gaussian) downed versions of the original image. For each entry on the pyramid, a sliding window approach is used. The sliding window concept is quite simple. By looping over an image with a constant step size, small image patches typically of size 64 x 128 pixels are extracted at different scales. For each patch, the algorithm makes a decision if it contains a face or not. The HOG is computed for the current window and passed to the SVM classifier (Linear or not) for the decision to take place (i.e. Face or not).

Face detection is the key to get perfect alignment of your filter

After face detection, it just follows a flow of sequence:-

  • Defining the model architecture(Convolutional Neural Networks)
  • Compile and Fit the model along with wrapping the datasets,i.e. referencing the datasets for test and train. This step also includes considering any harcasscade files for reference.
  • Initializing the webcam data, models and face detection input using cascading classifiers.
  • Finally matching the matrices of the facial keypoints to the points where you are aiming to apply your filter on e.g if its a sunglass, then you must focus on the orbit of the eye.

Start with a basic filter, adding one or two features to understand the control flow. This link provides you everything to get started.

Filter making: To add effects to an image

If you want to add a definition to your image or blur certain parts, no need to opt for Photoshop. The beauty of creating your very own filter is that you are in the entire control of everything. So you need not browse through the limited options of filters your photo editor provides you. Now to get started, we would need the predefined packages of OpenCV which contain numerous lines of optimized codes with statistical and probabilistic characteristics.

There are three basic ingredients to any Instagram filter:

  1. Sharpening or Blurring
  2. Adjusting channels by linear interpolation
  3. Splitting the hue channels and then interpolating them together along with the modifications.

The following are examples of some of the image processing outputs using OpenCV functions.

Applying Cannyedge effect to an image
Applying Vintage effect to an image

To understand better practically, click here.

Filter making: The shortcut way

Don't know how to code or have any interest in writing lines of codes? I got you covered. Facebook has a product called SparkAR which is an augmented reality platform for Mac & Windows that allows you to somewhat easily create AR effects for mobile cameras.

It's just like any other photo editors but with a higher customizable section and of course AR. With a few drag and drop features, a few couples of minutes and an exquisite idea, your filter will be licensed by Instagram and will be live.

To know more about SparkAR click here.

Learn about making your very first IG filter and launch it under your name by browsing here.

Cosmetic industries are using filters which virtually simulates their products

In terms of business, the image filter industry has contributed much to enhancing the sales rate. Just a month ago, Instagram made a calculated profit of $20millions just with its SparkAR contribution.

Especially cosmetic and jewelry industries are relying on filters so that they could give a virtual experience of their product. This boosts their sales also the customers get to try their product on them virtually to get a better experience. Be it Kylie Jenner’s Lip lines or labels like Off-White which offered their clients to try their sunglasses before launching at the Paris Fashion Week.

This comes to a wrap of our blog. We need to understand that the field of Computer Vision which houses Filter Making is pretty vast and I have tried to touch the tip of it through the blog.

Filter Making is a classic example of where technology meets with art. So never curb your imagination and the thirst for knowledge. As the amalgamation of both results in something phenomenal!. So, keep learning!

--

--

Debalina De
DSC CGC
Editor for

||Anchor and Content Creator at DSC CGC|| ||Technophile|| ||Book worm|| ||Daydreamer||