当前位置: 首页>>代码示例>>C++>>正文


C++ ofPixels::getChannel方法代码示例

本文整理汇总了C++中ofPixels::getChannel方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPixels::getChannel方法的具体用法?C++ ofPixels::getChannel怎么用?C++ ofPixels::getChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ofPixels的用法示例。


在下文中一共展示了ofPixels::getChannel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pixelateInv

void ofxImageTS::pixelateInv(ofPixels pixels, int pixelRatio, int X, int Y, int W, int H) {
    ofPixels R,G,B, Rc, Gc, Bc;
    pixels.resize(W,H);
    R = pixels.getChannel(0);
    G = pixels.getChannel(1);
    B = pixels.getChannel(2);
    Rc = R;
    Gc = G;
    Bc = B;
    int c = 0;
    for(int i = R.size()-1; i > 0; i--){
        Rc[c] = R[i];
        Gc[c] = G[i];
        Bc[c] = B[i];
        c++;
    }
    if(pixelRatio > 4 || pixelRatio < 0) {
        ofLogNotice("Pixel Ratio must be between 0 and 5");
    }
    else {
        
        int camWidth = pixels.getWidth();
        int camHeight = pixels.getHeight();
        int boxWidth = pixels.getWidth()/(pow(2,pixelRatio)*10);
        int boxHeight = pixels.getHeight()/(pow(2,pixelRatio)*10);
        
        float tot = boxWidth*boxHeight;
        for (int x = 0; x < camWidth; x += boxWidth) {
            for (int y = 0; y < camHeight; y += boxHeight) {
                float Red = 0, Green = 0, Blue = 0;
                for (int k = 0; k < boxWidth; k++) {
                    for (int l = 0; l < boxHeight; l++) {
                        int index = (x + k) + (y + l) * camWidth;
                        Red += Rc[index];
                        Green += Gc[index];
                        Blue += Bc[index];
                    }
                    ofSetColor(Red/tot,Green/tot,Blue/tot);
                    ofFill();
                    ofDrawRectangle(x+X, y+Y, boxWidth, boxHeight);
                }
            }
        }
    }
}
开发者ID:essteban,项目名称:ofxImageTS,代码行数:45,代码来源:ofxImageTS.cpp

示例2: calculateFlow

void threadedOpticalFlow::calculateFlow(const ofPixels& _pixels){
    lock();
    
    // realocate if size changed since last update
    if(_pixels.getWidth() != width  &&  _pixels.getHeight() != height){
        width = _pixels.getWidth();
        height = _pixels.getHeight();
        allocateBuffers(width, height);
    }
    
    // deep copy of incoming pixels
    // asumes same values in all channels
    //pixelsInBack.setChannel(0, _pixels.getChannel(0));
    pixelsInBack = _pixels.getChannel(0);
    
    bFlowDirty = true;
    
    condition.signal();
    
    unlock();
}
开发者ID:mimetikxs,项目名称:fluidWallTate,代码行数:21,代码来源:threadedOpticalFlow.cpp


注:本文中的ofPixels::getChannel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。