image filters

11
Image filters with OpenCV AN OVERVIEW www.inplac.es

Upload: inplacesapp

Post on 05-Dec-2014

844 views

Category:

Documents


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Image filters

Image filters with OpenCVAN OVERVIEW

www.inplac.es

Page 2: Image filters

IMAGE BLEND MODES

Image blend modes“Modes determine how two layers are blended into each other” – Wikipedia

Really nice looking image filters can be created using two of the most basic image blend modes

•OVERLAY•ADD(Most of the filters in InPlaces app uses just these two blends)(screenshot of image blending modes available in

Adobe Photoshop)

Page 3: Image filters

EXAMPLE

FilmThick filterUses just the Overlay and Add blend mode & is a result of two very basic steps if you use Photoshop or any other image editing software.

(screenshot from InPlaces app with FilmThick filter)

Page 4: Image filters

FILMTHICK FILTER

STEP 1 : Duplicate layer_1 as layer_2 and do the overlay

STEP 2 : Create a new layer_3 with RGB (154, 0, 205) & alpha at 22% and add it over layer_1 and layer_2

Try this with your favorite photo editing tool (Adobe Photoshop, Corel PhotoPaint)

Page 5: Image filters

DOING IT WITH OPENCV

OpenCV is a library of programming functions for real time computer vision. In simple words playing with your images and videos.

Modules of OpenCVcore, imgproc, video, calib3d, features2d, objdetect, highgui, gpu

All you needimgproc module

Website : http://opencv.org

Page 6: Image filters

OPENCV BASICS

How we see How OpenCV sees, A Matrix (data type: cvMat)

NOTE: RGB image has 3 layers &could be split into the contributing 3 channels usingOpenCV’s split() function

Page 7: Image filters

THE CODE

cv::Mat filmThick (cv::Mat src){cv::Mat colorTone;

src = overlay(src, src);

colorTone = cv::imread("rgb_154_0_205.jpg“);

addWeighted(src, 1.0, colorTone, 0.22, 0, src);

return (src);}

(Result of Step 1 from Slide 4)

(Result of step 2)

Page 8: Image filters

THE CODE – FUNCTIONS()

addWeightedOpenCV comes with the addWeighted function. This is nothing but the "Add" blend you see in Photoshop. Check doc here

OverlayOpenCV does not come with a function to perform overlay blend. So we had to code it.

Technically the algorithm happens to bereturn (v2 < 128) ? (2 * v1 * v2 / 255):(255 - 2 * (255 - v1) * (255 - v2) / 255);

V1 being the intensity of any given pixel from the sourceV2 being the intensity of any given pixel from the overlaying image

Page 9: Image filters

THE CODE - EXPLAINED

https://gist.github.com/inplacesapp/5415458

Check out the sample C++ code

Page 10: Image filters

ONE MORE TIP

Vignetting

Page 11: Image filters

THE END

www.inplac.es“inplacesapp” on twitter & facebook