学习OpenCV:滤镜系列(3)——颜色变幻

【原文:http://blog.csdn.net/yangtrees/article/details/9096435

==============================================

版权所有:小熊不去实验室CSDN博客

==============================================

使用 applyColorMap()

 enum
    {
        COLORMAP_AUTUMN = 0,
        COLORMAP_BONE = 1,
        COLORMAP_JET = 2,
        COLORMAP_WINTER = 3,
        COLORMAP_RAINBOW = 4,
        COLORMAP_OCEAN = 5,
        COLORMAP_SUMMER = 6,
        COLORMAP_SPRING = 7,
        COLORMAP_COOL = 8,
        COLORMAP_HSV = 9,
        COLORMAP_PINK = 10,
        COLORMAP_HOT = 11
    }


  1. #include <math.h>  
  2. #include <opencv2/contrib/contrib.hpp>  
  3. #include <opencv2/core/core.hpp>  
  4. #include <opencv2/highgui/highgui.hpp>  
  5.   
  6. using namespace cv;  
  7. using namespace std;  
  8.   
  9. int main()  
  10. {  
  11.     Mat src = imread("D:/img/face03.jpeg",1);  
  12.     int width = src.cols;  
  13.     int heigh = src.rows;  
  14.     Mat gray;  
  15.     Mat imgColor[12];  
  16.     Mat display(heigh*3,width*4,CV_8UC3);  
  17.   
  18.     cvtColor(src,gray,CV_BGR2GRAY);  
  19.     for(int i=0; i<12; i++)  
  20.     {  
  21.         applyColorMap(gray,imgColor[i],i);  
  22.         int x=i%4;  
  23.         int y=i/4;  
  24.         Mat displayROI = display(Rect(x*width,y*heigh,width,heigh));  
  25.         resize(imgColor[i],displayROI,displayROI.size());  
  26.     }  
  27.     imshow("colorImg",display);   
  28.     waitKey();  
  29.     imwrite("D:/img/幻彩颜色02.jpg",display);  
  30. }  

原图:


颜色变幻


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值