zoukankan      html  css  js  c++  java
  • 操作MAT矩阵(转)

        t = (double)getTickCount();
        Mat img1(1000, 1000, CV_32F);
        
        for (int i=0; i<1000; i++)
        {
            for (int j=0; j<1000; j++)
            {
                img1.at<float>(i,j) = 3.2f;
            }
        }
        t = (double)getTickCount() - t;
        printf("in %gms
    ", t*1000/getTickFrequency());
        //***************************************************************
        t = (double)getTickCount();
        Mat img2(1000, 1000, CV_32F);
    
        for (int i=0; i<1000; i++)
        {
            for (int j=0; j<1000; j++)
            {
                img2.ptr<float>(i)[j] = 3.2f;
            }
        }
        t = (double)getTickCount() - t;
        printf("in %gms
    ", t*1000/getTickFrequency());
        //***************************************************************
        t = (double)getTickCount();
        Mat img3(1000, 1000, CV_32F);
        float* pData = (float*)img3.data;
    
        for (int i=0; i<1000; i++)
        {
            for (int j=0; j<1000; j++)
            {
                *(pData) = 3.2f;
                pData++;
            }
        }
        t = (double)getTickCount() - t;
        printf("in %gms
    ", t*1000/getTickFrequency());
        //***************************************************************
        t = (double)getTickCount();
        Mat img4(1000, 1000, CV_32F);
    
        for (int i=0; i<1000; i++)
        {
            for (int j=0; j<1000; j++)
            {
                ((float*)img3.data)[i*1000+j] = 3.2f;
            }
        }
        t = (double)getTickCount() - t;
        printf("in %gms
    ", t*1000/getTickFrequency());

    http://blog.csdn.net/yang_xian521/article/details/7161335

  • 相关阅读:
    外星人(alien)
    6. 第 6 章 函数
    5. 第 5 章 循环
    4. 第 4 章 条件选择
    3. 第 3 章 表达式和交互
    2. 第 2 章 C++简介
    1. 第 1 章 计算机和编程简介
    24. 蛇形填数
    23. 开灯问题
    12. aabb
  • 原文地址:https://www.cnblogs.com/chchche/p/3185249.html
Copyright © 2011-2022 走看看