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


C++ ofImage::setColor方法代码示例

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


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

示例1: update

 void update() {
     cam->update();
     if(cam->isFrameNew()) {
         ofPixels& pix = cam->getPixels();
         int skip = 2;
         int range = mouseX / 25;
         for(int y = 0; y < pix.getHeight(); y += skip) {
             for(int x = 0; x < pix.getWidth(); x += skip) {
                 ofColor cur = pix.getColor(x, y);
                 ofColor result(0, 0, 0, 0);
                 if(cur.r < range || cur.r > 255-range) {
                     result.r = 255;
                     result.a = 255;
                 }
                 if(cur.g < range || cur.g > 255-range) {
                     result.g = 255;
                     result.a = 255;
                 }
                 if(cur.b < range || cur.b > 255-range) {
                     result.b = 255;
                     result.a = 255;
                 }
                 clipping.setColor(x, y, result);
             }
         }
         clipping.update();
         
         if(recording) {
             string fn = "images/" + ofToString(frameCount, 6, '0') + ".jpg";
             imageSaver.saveImage(pix, fn);
             frameCount++;
         }
     }
 }
开发者ID:kylemcdonald,项目名称:SharingFaces,代码行数:34,代码来源:main.cpp

示例2: sobel

void sobel(Field &field, ofImage &edges, ofPixels &pix) {
    // Sobel gradient
    #define VAL(x, y) pix.getColor(x, y).r
    float mag;
    for (int i = 1; i < 1023; ++i)
        for (int j = 1; j < 767; ++j)
        {
            ofVec2f g(0, 0);
            // left
            g.y -= 2 * VAL(i - 1, j);
            g.y -= VAL(i - 1, j - 1);
            g.y -= VAL(i - 1, j + 1);
            // right
            g.y += 2 * VAL(i + 1, j);
            g.y += VAL(i + 1, j - 1);
            g.y += VAL(i + 1, j + 1);
            // up
            g.x += 2 * VAL(i, j - 1);
            g.x += VAL(i - 1, j - 1);
            g.x += VAL(i + 1, j - 1);
            // down
            g.x -= 2 * VAL(i, j + 1);
            g.x -= VAL(i - 1, j + 1);
            g.x -= VAL(i + 1, j + 1);
            // uniform
            if (g.x < 0)
                g = -g;
            if (g.x == 0)
                g.y = fabs(g.y);
            
            field.set(i, j, 50*g.normalized());
            mag = abs(g.x) + abs(g.y);
            edges.setColor(i, j, ofColor(mag));
        }
}
开发者ID:nikki93,项目名称:spe,代码行数:35,代码来源:App.cpp

示例3: loadStencilFromHex

void ofxBaseGui::loadStencilFromHex(ofImage& img, unsigned char* data) {
	int width = img.getWidth();
	int height = img.getHeight();
	int i = 0;
	ofColor on(255, 255);
	ofColor off(255, 0);
	for(int y = 0; y < height; y++) {
		for(int x = 0; x < width; x++) {
			int shift = i % 8;
			int offset = i / 8;
			bool cur = (data[offset] >> shift) & 1;
			img.setColor(x, y, cur ? on : off);
			i++;
		}
	}
	img.update();
}
开发者ID:imclab,项目名称:LaserShow,代码行数:17,代码来源:ofxBaseGui.cpp

示例4: faceColorToTexture

void faceColorToTexture(ofMesh& mesh, ofImage& image)
{
	vector<ofFloatColor> &color = mesh.getColors();
	int num_face = color.size() / 3;
	
	int tex_size = ofNextPow2(ceil(sqrt(num_face)));
	
	bool arb = ofGetUsingArbTex();
	ofDisableArbTex();
	image.allocate(tex_size, tex_size, OF_IMAGE_COLOR);
	if (arb) ofEnableArbTex();
	
	mesh.clearTexCoords();
	
	image.getPixelsRef().set(0);
	
	float texel_size = (1. / image.getWidth()) * 0.5;
	
	for (int i = 0; i < num_face; i++)
	{
		int u = (i % tex_size);
		int v = (i / tex_size);
		
		ofColor c = color[i * 3];
		
		image.setColor(u, v, c);
		
		float uu = (float)u / image.getWidth() + texel_size;
		float vv = (float)v / image.getHeight() + texel_size;
		
		mesh.addTexCoord(ofVec2f(uu, vv));
		mesh.addTexCoord(ofVec2f(uu, vv));
		mesh.addTexCoord(ofVec2f(uu, vv));
	}
	
	image.update();
	mesh.clearColors();
}
开发者ID:hanasaan,项目名称:ofxObjLoader,代码行数:38,代码来源:ofxObjLoader.cpp

示例5: draw

//--------------------------------------------------------------
void ofApp::draw(){
    
    //Merci Ludo pour ton aide
	
    currentFrame = vidGrabber.getPixelsRef();
    currentFrameCopy.allocate(currentFrame.getWidth(), currentFrame.getHeight(), OF_IMAGE_GRAYSCALE);


    for(int x=0 ; x < 256 ; x++) {
        histogram[x] = 0;
    }

    
    for (int i = 0; i < camWidth; i++){
        for (int j = 0; j < camHeight; j++){
            int lightness = currentFrame.getColor(i,j).getLightness();
            histogram[lightness] = histogram[lightness]+1;
            ofColor pixel;
            pixel.set(lightness, lightness, lightness);
            currentFrame.setColor(i, j, pixel);

        }
    }
    
    ofSetHexColor(0xffffff);
    currentFrame.reloadTexture();
    currentFrame.draw(0,0);
    
    ofFill();
	ofSetHexColor(0x000000);
	ofSetPolyMode(OF_POLY_WINDING_ODD);
    
    ofLine(770, 400, 770, 400-255);
    ofLine(770, 400, 770+255, 400);
    
    histogramMax = 0;
    maxIndex = 0;
    for(int x = 0 ; x < 256 ; x++) {
        if (histogram[x]>histogramMax) {
            histogramMax = histogram[x];
            maxIndex = x;
            }
        histogram[x] = histogram[x]/100;
        //cout << x << " : " << histogram[x] << "\n";
        ofLine(x+770, 400-histogram[x], x+770, 400);
    }

    ofSetColor(255,0,0);
    ofLine(maxIndex+770, 400-histogram[maxIndex], maxIndex+770, 400);
    
    ofSetColor(0);
	ofDrawBitmapString("Histogram : ", 770, 100);
	ofDrawBitmapString("0                             255 ", 770, 415);
	ofDrawBitmapString("0", 755, 400);
	ofDrawBitmapString("???", 773, 150);

    threshold = 128;
    for(int y = 0; y < camHeight; y++) {
        for(int x = 0; x < camWidth; x++) {
            ofColor cur = currentFrame.getColor(x, y);
            int lightness = cur.getLightness();
            ofColor pixel;
            if (lightness<threshold) pixel.set(0, 0, 0);
            else pixel.set(255, 255, 255);
            currentFrameCopy.setColor(x, y, pixel);
        }
    }
    
    ofSetColor(255);
    currentFrameCopy.reloadTexture();
    currentFrameCopy.draw(0, 480);


    

}
开发者ID:RudiGiot,项目名称:AutoAdaptiveBinarization,代码行数:77,代码来源:ofApp.cpp


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