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