Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Inverting Colors

$
0
0

@doleyl1 wrote:

Using a basic slitscanner code, I am trying to get the slitscan image to change and invert colors once a key is pressed. I uploaded the ofxOpenCV library, and tried to use .invert, but that didn’t work.

Here is the code that I thought would try and change the colors of the slit scan, but it is not doing anything.
`void ofApp::keyPressed(int key){

// if (key == 32){

cout << "Key Pressed";
    ofImage slitScanInvert = slitScanImage;
    ofPixels ssPixels = slitScanInvert.getPixels();
    
    // 1. get pixels from copied ofImage
    // 2. get the color of each pixels
    // 3. invert the color from eac pixel
    // 4. write new color back to the image
    
    for (int col = 0; col < slitScanInvert.getWidth(); col++) {
        for (int row = 0; row < slitScanInvert.getHeight(); row++) {
            ofColor c = ssPixels.getColor(col, row);
            ssPixels.setColor(col, row, c.invert());
        }
    }
    
    slitScanInvert.draw(200, camHeight+40);
}`

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles