zoukankan      html  css  js  c++  java
  • 实验1

    #include<opencv2/core.hpp>
    #include<opencv2/highgui.hpp>
    using namespace cv;
    
    void getChannel(const uchar *input, int width, int height,int inStep, int inChannels,uchar *output, int outStep, int channelToGet){
        for (int y = 0; y < height; ++y, input += inStep, output += outStep){
            const uchar *px = input;
            for (int x = 0; x < width; ++x, px += inChannels)
                output[x] = px[channelToGet];
        }
    }
    void getChannel(const Mat &in, Mat &output, int channelToGet)
    {
        getChannel(in.data, in.cols, in.rows, in.step, in.channels(), output.data, output.step, channelToGet);
    }
    
    int main()
    {
        Mat img = imread("f:/2008_000149.jpg", -1);
    
        Mat channel(img.size(), CV_8UC1);
        getChannel(img.data, img.cols, img.rows, img.step, img.channels(), channel.data, channel.step, 0);
        channel = 0;
    
        Rect roi(10, 10, 300, 300);
        getChannel(img.ptr(roi.y, roi.x), roi.width, roi.height, img.step, img.channels(),
        channel.ptr(roi.y, roi.x), channel.step, 0);
        getChannel(img(roi), channel(roi), 0);
    
        imshow("img", img);
        imshow("channel", channel);
        waitKey();
        return 0;
    }
  • 相关阅读:
    5. Redis持久化
    4.Redis客户端
    3.Redis高级功能
    2.Redis五种数据结构
    1.Redis简介
    32.Mysql Cluster
    suffix ACM-ICPC 2017 Asia Qingdao
    多层BFS
    我想和你们说说java和C++___C加加
    11073 最热门的K个搜索串
  • 原文地址:https://www.cnblogs.com/war1111/p/13709456.html
Copyright © 2011-2022 走看看