SlideShare a Scribd company logo
1 of 11
Image filters with OpenCV
AN OVERVIEW
www.inplac.es
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)
EXAMPLE
FilmThick filter
Uses 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)
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)
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 OpenCV
core, imgproc, video, calib3d, features2d, objdetect, highgui, gpu
All you need
imgproc module
Website : http://opencv.org
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 using
OpenCV’s split() function
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)
THE CODE – FUNCTIONS()
addWeighted
OpenCV comes with the addWeighted function. This is nothing but the
"Add" blend you see in Photoshop. Check doc here
Overlay
OpenCV does not come with a function to perform overlay blend. So we
had to code it.
Technically the algorithm happens to be
return (v2 < 128) ? (2 * v1 * v2 / 255):(255 - 2 * (255 - v1) * (255 - v2) /
255);
V1 being the intensity of any given pixel from the source
V2 being the intensity of any given pixel from the overlaying image
THE CODE - EXPLAINED
https://gist.github.com/inplacesapp/5415458
Check out the sample C++ code
ONE MORE TIP
Vignetting
THE END
www.inplac.es
“inplacesapp” on twitter & facebook

More Related Content

Similar to Image filters

Image Detection and Count Using Open Computer Vision (Opencv)
Image Detection and Count Using Open Computer Vision (Opencv)Image Detection and Count Using Open Computer Vision (Opencv)
Image Detection and Count Using Open Computer Vision (Opencv)IJERA Editor
 
Introduction to directshow II
Introduction to directshow IIIntroduction to directshow II
Introduction to directshow IIYoss Cohen
 
A Tutorial On Ip 2
A Tutorial On Ip 2A Tutorial On Ip 2
A Tutorial On Ip 2ankuredkie
 
Elizabeth Perry: Processing programming language, part 2
Elizabeth Perry: Processing programming language, part 2Elizabeth Perry: Processing programming language, part 2
Elizabeth Perry: Processing programming language, part 2ÚISK FF UK
 
OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)Chetan Allapur
 
OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012Wingston
 
Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...Krunal Patel
 
Orchid Programming
Orchid ProgrammingOrchid Programming
Orchid Programmingrayhsu
 
Matlab & C/C++ Interacting
Matlab & C/C++ InteractingMatlab & C/C++ Interacting
Matlab & C/C++ InteractingHamid Jamali
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCVAutomatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCVEditor IJCATR
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV Editor IJCATR
 
Intro_OpenCV.ppt
Intro_OpenCV.pptIntro_OpenCV.ppt
Intro_OpenCV.pptRithikRaj25
 
Practical Digital Image Processing 1
Practical Digital Image Processing 1Practical Digital Image Processing 1
Practical Digital Image Processing 1Aly Abdelkareem
 
2012 04-19 theory-of_operation
2012 04-19 theory-of_operation2012 04-19 theory-of_operation
2012 04-19 theory-of_operationbobwolff68
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotTsai Tsung-Yi
 
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLABFAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLABJournal For Research
 
When Smalltalk Meets the Web
When Smalltalk Meets the WebWhen Smalltalk Meets the Web
When Smalltalk Meets the WebESUG
 

Similar to Image filters (20)

Image Detection and Count Using Open Computer Vision (Opencv)
Image Detection and Count Using Open Computer Vision (Opencv)Image Detection and Count Using Open Computer Vision (Opencv)
Image Detection and Count Using Open Computer Vision (Opencv)
 
Introduction to directshow II
Introduction to directshow IIIntroduction to directshow II
Introduction to directshow II
 
A Tutorial On Ip 2
A Tutorial On Ip 2A Tutorial On Ip 2
A Tutorial On Ip 2
 
Elizabeth Perry: Processing programming language, part 2
Elizabeth Perry: Processing programming language, part 2Elizabeth Perry: Processing programming language, part 2
Elizabeth Perry: Processing programming language, part 2
 
OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)
 
OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012
 
Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
 
Orchid Programming
Orchid ProgrammingOrchid Programming
Orchid Programming
 
Introduction to VB.Net.pptx
Introduction to VB.Net.pptxIntroduction to VB.Net.pptx
Introduction to VB.Net.pptx
 
Matlab & C/C++ Interacting
Matlab & C/C++ InteractingMatlab & C/C++ Interacting
Matlab & C/C++ Interacting
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCVAutomatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV
 
Intro_OpenCV.ppt
Intro_OpenCV.pptIntro_OpenCV.ppt
Intro_OpenCV.ppt
 
Practical Digital Image Processing 1
Practical Digital Image Processing 1Practical Digital Image Processing 1
Practical Digital Image Processing 1
 
2012 04-19 theory-of_operation
2012 04-19 theory-of_operation2012 04-19 theory-of_operation
2012 04-19 theory-of_operation
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobot
 
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLABFAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
 
When Smalltalk Meets the Web
When Smalltalk Meets the WebWhen Smalltalk Meets the Web
When Smalltalk Meets the Web
 
Ijetr011814
Ijetr011814Ijetr011814
Ijetr011814
 

Image filters

  • 1. Image filters with OpenCV AN OVERVIEW www.inplac.es
  • 2. 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)
  • 3. EXAMPLE FilmThick filter Uses 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)
  • 4. 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)
  • 5. 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 OpenCV core, imgproc, video, calib3d, features2d, objdetect, highgui, gpu All you need imgproc module Website : http://opencv.org
  • 6. 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 using OpenCV’s split() function
  • 7. 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)
  • 8. THE CODE – FUNCTIONS() addWeighted OpenCV comes with the addWeighted function. This is nothing but the "Add" blend you see in Photoshop. Check doc here Overlay OpenCV does not come with a function to perform overlay blend. So we had to code it. Technically the algorithm happens to be return (v2 < 128) ? (2 * v1 * v2 / 255):(255 - 2 * (255 - v1) * (255 - v2) / 255); V1 being the intensity of any given pixel from the source V2 being the intensity of any given pixel from the overlaying image
  • 9. THE CODE - EXPLAINED https://gist.github.com/inplacesapp/5415458 Check out the sample C++ code