-
Notifications
You must be signed in to change notification settings - Fork 6
/
fresaliency.cpp
41 lines (33 loc) · 1.09 KB
/
fresaliency.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "fresaliency.h"
void FreSaliency::calSal()
{
// GaussianBlur
GaussianBlur(imgLab, gaussImg, Size(3, 3), 0, 0);
// Mean value of L*A*B
CvScalar meanChannels = mean(gaussImg);
double meanL = meanChannels.val[0];
double meanA = meanChannels.val[1];
double meanB = meanChannels.val[2];
imgSal = Mat(imgLab.size(), CV_32FC1);
int rows = imgSal.rows;
int cols = imgSal.cols;
for(int i=0; i < rows; i++)
{
for(int j=0; j < cols; j++)
{
Vec3i iLab = gaussImg.at<Vec3b>(i,j);
imgSal.at<float>(i,j) = (float(iLab.val[0]) - meanL)*(float(iLab.val[0]) - meanL) +
(float(iLab.val[1]) - meanA)*(float(iLab.val[1]) - meanA) +
(float(iLab.val[2]) - meanB)*(float(iLab.val[2]) - meanB);
}
}
normalize(imgSal, imgSal, 1.0, 0.0, NORM_MINMAX);
}
void FreSaliency::segMs()
{
int spatialRad=25,colorRad=45,maxPryLevel=1;
pyrMeanShiftFiltering(imgRGB, imgMs, spatialRad, colorRad, maxPryLevel);
}
FreSaliency::~FreSaliency()
{
}