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

    #include <bits/stdc++.h>
    #define inf 2333333333333333
    #define N 1000010
    #define p(a) putchar(a)
    #define For(i,a,b) for(int i=a;i<=b;++i)
    typedef unsigned char uchar;
    //by war
    //2020.9.15
    using namespace std;
    using namespace cv;
    uchar b[10000010];
    Mat image0,image1,temp,temp0;
    vector<Mat> v;
    int pos;
    void in(int &x){
        int y=1;char c=getchar();x=0;
        while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
        while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
        x*=y;
    }
    void o(int x){
        if(x<0){p('-');x=-x;}
        if(x>9)o(x/10);
        p(x%10+'0');
    }
    
    uchar*  get_pixel(const uchar *img, int x, int y,int step){
            return (uchar*)(img+y*step+x*3);
    }
    
    
    void getChannel(const uchar *input, int width, int height, int inStep, int inChannels,  int channelToGet ){
        pos=0;
        For(i,0,height-1)
            For(j,0,width-1){
                auto k=get_pixel(input,j,i,inStep);
                b[pos++]=*(k+channelToGet);
            }
    }
    
    
    signed main(){
        For(i,0,2){
            image0=imread("/Users/war/Downloads/dog.PNG");
            v.clear();
            temp = image0(Rect(700,700,700,700));
            For(i,1,3) v.push_back(Mat::zeros(temp.cols, temp.rows, CV_8UC1));
            getChannel(temp.data, temp.cols, temp.rows, (int)temp.step, temp.channels(),i);
            Mat image (temp.cols, temp.rows, CV_8UC1, b, temp.cols);
            v[i]=image;
            merge(v,image);
            image.copyTo(image0(Rect(300,300,700,700)));
            imshow("dog",image0);
            waitKey(-1);
        }
        imshow("dog",image0);
        waitKey(-1);
        return 0;
    }

     

  • 相关阅读:
    判断arm立即数是否合法的小程序
    一个操作系统的实现:关于ALIGN的若干解释
    一个郁闷的C语言小问题
    test
    浮点数的比较
    一个操作系统的实现:Descriptor 3详解
    一个操作系统的实现:关于CPL、RPL、DPL
    C99可变长数组VLA详解
    SVProgressHUD 用法
    IOS CALayer 详解
  • 原文地址:https://www.cnblogs.com/war1111/p/13676407.html
Copyright © 2011-2022 走看看