opencv实战从0到N (12)—— Lab颜色空间与显著性分析

opencv实战从0到N (12)—— Lab颜色空间与显著性分析

1,Lab空间:

Lab色彩模型是由亮度(L)和有关色彩的a, b三个要素组成。L表示亮度(Luminosity),a表示从洋红色至绿色的范围,b表示从黄色至蓝色的范围。

L的值域由0到100,L=50时,就相当于50%的黑;a和b的值域都是由+127至-128,其中+127 a就是红色,渐渐过渡到-128 a的时候就变成绿色;

同样原理,+127 b是黄色,-128 b是蓝色。所有的颜色就以这三个值交互变化所组成。例如,一块色彩的Lab值是L = 100,a = 30, b = 0,

这块色彩就是粉红色。(注:此模式中的a轴,b轴颜色与RGB不同,洋红色更偏红,绿色更偏青,黄色略带红,蓝色有点偏青色)(引自百科)

使用opencv转换: cvtColor(src, LabImage, CV_BGR2Lab);

 

2,显著性分析:

参考论文: Frequency-tuned Salient Region Detection, Radhakrishna Achantay, Page 4-5, 2009 CVPR

这篇论文对显著性检测提出了以下5个指标:

1、 Emphasize the largest salient objects.

2、Uniformly highlight whole salient regions.

3、Establish well-defined boundaries of salient objects.

4、Disregard high frequencies arising from texture, noise and blocking artifacts.

5、Efficiently output full resolution saliency maps.

在LAB空间实现其实就是将三个通道的颜色减去各自的平均值后平方再求和。

我用opencv实现如下,不知道为什么效果有出入,做了些调整。

void FT(Mat& src)
{
    Mat LabImage;
    cvtColor(src, LabImage, CV_BGR2Lab);
    vector channels_lab;
    Mat L, A, B;
    split(LabImage, channels_lab);
    L = channels_lab.at(0);
    A = channels_lab.at(1);
    B = channels_lab.at(2);
    CvScalar L_mean = mean(L);
    CvScalar A_mean = mean(A);
    CvScalar B_mean = mean(B);
    GaussianBlur(LabImage, LabImage, Size(3, 3), 0, 0, BORDER_DEFAULT);
    //imshow("LabImage", LabImage);
    //imshow("L", L);
    vector channels_lab1;
    Mat L1, A1, B1;
    split(LabImage, channels_lab1);
    L1 = channels_lab1.at(0);
    A1 = channels_lab1.at(1);
    B1 = channels_lab1.at(2);
    L1 = abs(L1 - Scalar(L_mean.val[0]));
    A1 = abs(A1 - Scalar(A_mean.val[0]));
    B1 = abs(B1 - Scalar(B_mean.val[0]));
   
    Mat t1 = L1.clone();
    Mat t2 = A1.clone();
    Mat t3 = B1.clone();
    Mat d1 = L1.mul(t1);
    Mat d2 = A1.mul(t2);
    Mat d3 = B1.mul(t3);

    Mat dst = L1 + A1 + B1;
    //Mat dst2 = d1 + d2 + d3;
   // Mat N_dst;
   // normalize(dst, N_dst,255);
    imshow("dst", dst);
   // imshow("dst2", dst2);
  
}


opencv实战从0到N (12)—— Lab颜色空间与显著性分析_第1张图片

显著性分析

你可能感兴趣的:(OPENCV,OPENCV从0到N)