That’s the saliency of the ad, the part that pulls your interest even when you just saw it in a glance.
Installing OpenCVFirst thing first, you need to install OpenCV library.
If you already have pip installed, you can do it by running these commands.
> pip install opencv-python> pip install opencv-contrib-pythonTo verify the installation, you can run these commands.
> pythonPython 3.
6.
3 (v3.
6.
3:2c5fed8, Oct 3 2017, 18:11:49)Type "help", "copyright", "credits" or "license" for more information.
>> import cv2>> cv2.
saliency <module 'cv2.
saliency'>Static Saliency DetectionThere are many ways to detect saliency.
In OpenCV, algorithms provided for saliency detection are divided into three categories:Saliency Diagram.
Source : OpenCV DocumentationWe will talk about static saliency.
Static saliency detection algorithms use different image features that allow detecting salient object of a non-dynamic image.
There are two algorithms that already implemented in OpenCV, spectral residual and fine grained.
Spectral ResidualThis algorithm analyzes the log-spectrum of an input image, extracts the spectral residual of an image in the spectral domain, and proposes a fast method to construct saliency map which suggests the positions of proto-objects.
Similarities imply redundancies.
For a system aiming at minimizing the redundant visual information, it must be aware of the statistical similarities of the input stimuli.
Therefore, in different log spectra where considerable shape similarities can be observed, what deserves our attention is the information that jumps out of the smooth curves.
We believe that the statistical singularities in the spectrum may be responsible for anomalous regions in the image, where proto-objects are popped up.
And if you plot the saliency map, you will get the output image below.
Spectral ResidualReference: Hou, Xiaodi, and Liqing Zhang.
“Saliency detection: A spectral residual approach.
” Computer Vision and Pattern Recognition, 2007.
CVPR‘07.
IEEE Conference on.
IEEE, 2007.
Fine GrainedThe retina of the human eyes consists of ganglion cells.
There are two types of ganglion cells, on-center and off-center.
The on-center responds to bright areas surrounded by a dark background.
The off-center responds to dark areas surrounded by a bright background.
This algorithm calculates the saliency based on the on-center and off-center differences.
On-center and off-center ganglion cells and their approximation on computational models of visual saliency.
Source: B.
Wang and P.
Dudek “A Fast Self-tuning Background Subtraction Algorithm”, in proc of IEEE Workshop on Change Detection, 2014In our case, by using an efficient implementation ofcenter-sorround differences through the so-called integral image, we demonstrate a method to generate fine grained feature maps of visual saliency operating in real time at the original image resolution.
And if you plot the saliency map, you will get the output image below.
Reference: B.
Wang and P.
Dudek “A Fast Self-tuning Background Subtraction Algorithm”, in proc of IEEE Workshop on Change Detection, 2014ReferenceOpenCV: cv::saliency::Saliency Class ReferencePublic Member Functions | Protected Member Functions | Protected Attributes | List of all membersdocs.
opencv.
orghttps://docs.
opencv.
org/3.
4/d9/dcd/classcv_1_1saliency_1_1Saliency.
html.. More details