码迷,mamicode.com
首页 > 其他好文 > 详细

opencv学习

时间:2014-11-19 17:37:21      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:des   io   ar   color   os   使用   sp   for   on   

使用查找表LUT

#include <cv.h>
#include <highgui.h>
#include <stdio.h>
using namespace std;
using namespace cv;
int main(int argc, char **argv)
{
    double t = (double)getTickCount();

    const char *srcfile = argv[1];
    Mat srcimg;
    srcimg = imread(srcfile, CV_LOAD_IMAGE_COLOR);
    namedWindow("foggy", CV_WINDOW_AUTOSIZE);
    imshow("foggy", srcimg);
    //waitKey(0);

    uchar r = 7;
    Mat mask = Mat::ones(2 * r + 1, 2 * r + 1, CV_8UC1);
    uchar nc = srcimg.channels(), nrows = srcimg.rows, ncols = srcimg.cols*nc,i,j;
    if (srcimg.isContinuous())
    {
        ncols *= nrows;
        nrows = 1;
    }

    Mat lookUpTable(1, 256, CV_8U);
    uchar *p = lookUpTable.data;
    for (int i = 0; i < 256; ++i)
        p[i] = i / 32 * 32;
    Mat des;
    LUT(srcimg, lookUpTable, des);
    namedWindow("out", CV_WINDOW_AUTOSIZE);
    imshow("out", des);
    waitKey(0);
        /*MatIterator_<Vec3b> it, end;
        for (it = srcimg.begin<Vec3b>(), end = srcimg.end<Vec3b>(); it != end; ++it)
        {
        (*it)[0]=

        }

        */

    t = ((double)getTickCount() - t) / getTickFrequency();
    cout << "Time passed in seconds :" << t << endl;
    return 0;
}

opencv学习

标签:des   io   ar   color   os   使用   sp   for   on   

原文地址:http://www.cnblogs.com/mintmy/p/4108378.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!