ofxCv functions change number of ofPixel channels

Hey all,

I’m doing some CV work with a lot of cameras and trying to keep overhead low by only working with grayscale, single channel data. However, when using certain ofxCv methods, my data is converted to more than 1 channel. I traced it down to a few functions I was using surrounded by some console logging to debug:

    cout << "-----Before Gaussian: -----" << endl;
    cout << "threshPix Channels: " << threshPix.getNumChannels() << endl;
    cout << "BlurredPix Channels: " << blurredPix.getNumChannels() << endl;
    
    //blur it
    ofxCv::GaussianBlur(grayPix, blurredPix, cameraGui.blurAmountSlider);
    
    cout << "-----Before Thresholding: -----" << endl;
    cout << "threshPix Channels: " << threshPix.getNumChannels() << endl;
    cout << "BlurredPix Channels: " << blurredPix.getNumChannels() << endl;
    
    //threshold it
    ofxCv::threshold(blurredPix, threshPix, cameraGui.thresholdSlider);
    
    cout << "-----After Thresholding: -----" << endl;
    cout << "threshPix Channels: " << threshPix.getNumChannels() << endl;
    cout << "BlurredPix Channels: " << blurredPix.getNumChannels() << endl;

The output is below:

-----Before Gaussian: -----
threshPix Channels: 1
BlurredPix Channels: 1
-----Before Thresholding: -----
threshPix Channels: 1
BlurredPix Channels: 4
-----After Thresholding: -----
threshPix Channels: 4
BlurredPix Channels: 4

It would be nice if I can keep everything one channel since all the extra computation is unnecessary. @kylemcdonald Is this a bug in ofxCv or is this 4 channel output intentional? Should I submit an issue to the repo?

Just trying to bump this up a bit. Would love to know how to run these methods and still keep my data as single channel, grayscale!

can you add a debug trace at the very beginning to printout

cout << "grayPix Channels: " << grayPix.getNumChannels() << endl;

the only way i can imagine the other images would be converted to use 4 channels is if your original graPix image would also be 4 channels. if that’s the case transform it first to 1 channel and the rest will stay at 1 channel too

Oh, I’m a dummy. The issue does start earlier up the chain. Gray pix is showing as 4 channels even though I initialize it as one channel. Before the code above I am filling grayPix with the contents of an FBO with “fbo.readToPixels(grayPix)” and THAT’s what’s moving my data to 4 channels. Duh.

Thanks.