void ofxAcv::apply(const ofPixelsRef src, ofPixelsRef dst) { if (src.getWidth() != dst.getWidth() || src.getHeight() != dst.getHeight() || src.getNumChannels() != dst.getNumChannels()) { ofLogNotice() << "reallocating dst"; dst.allocate(src.getWidth(), src.getHeight(), src.getNumChannels()); } int w = src.getWidth(); int h = src.getHeight(); int ch = src.getNumChannels(); assert(ch <= curves.size()); unsigned char* srcPixels = src.getPixels(); unsigned char* dstPixels = dst.getPixels(); for (int y=0; y<h; ++y) { for (int x=0; x<w; ++x) { for (int c=0; c<ch; ++c) { int idx = (y * w + x) * ch + c; dstPixels[idx] = curves[c][srcPixels[idx]]; } } } }