本文整理汇总了C++中ofFloatImage::update方法的典型用法代码示例。如果您正苦于以下问题:C++ ofFloatImage::update方法的具体用法?C++ ofFloatImage::update怎么用?C++ ofFloatImage::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofFloatImage
的用法示例。
在下文中一共展示了ofFloatImage::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupSpeakers
void setupSpeakers() {
ofVec3f speakers[n_speakers];
// maybe need to swap dimensions here?
// possibly change scale too
float eps = 0.001; // needed to avoid "== 0" check in shader
speakers[0] = ofVec3f(0,0,0)+eps; // front left
speakers[1] = ofVec3f(0,1,0)+eps; // front right
speakers[2] = ofVec3f(1,1,0)+eps; // rear right
speakers[3] = ofVec3f(1,0,0)+eps; // rear left
float speakerAreaSize = 0.02;
speakerXyzMap.allocate(n_samples, n_speakers, OF_IMAGE_COLOR_ALPHA);
speakerConfidenceMap.allocate(n_samples, n_speakers, OF_IMAGE_COLOR_ALPHA);
float* xyzPixels = speakerXyzMap.getPixels().getData();
float* confidencePixels = speakerConfidenceMap.getPixels().getData();
for(int i = 0; i < n_speakers; i++){
for(int j = 0; j < n_samples; j++){
// sample a spiral
float angle = j * TWO_PI / 20; // 20 samples per full rotation
float radius = ((float) j / n_samples) * speakerAreaSize; // 0 to speakerAreaSize
// might need to swap axes here too
xyzPixels[0] = speakers[i].x + sin(angle) * radius;
xyzPixels[1] = speakers[i].y + cos(angle) * radius;
xyzPixels[2] = speakers[i].z;
xyzPixels[3] = 1;
xyzPixels += 4;
confidencePixels[0] = 1;
confidencePixels[1] = 1;
confidencePixels[2] = 1;
confidencePixels[3] = 1;
confidencePixels += 4;
}
}
speakerXyzMap.update();
speakerConfidenceMap.update();
speakerFbo.allocate(n_samples, n_speakers);
speakerPixels.allocate(n_samples, n_speakers, OF_IMAGE_COLOR_ALPHA);
}
示例2: ofNoise
void
testApp::renderNoise(ofFloatImage &img)
{
double maxval = 0.0;
double minval = 10.0;
for (int i = 0; i < img.getWidth(); i++) {
for (int j = 0; j < img.getHeight(); j++) {
double sum = 0;
double scale = 1.0;
double p[2];
p[0] = i /(float)img.getWidth() + offset;
p[1] = j /(float)img.getHeight();
for (int k = 0; k < images.size(); k++) {
double val = ofNoise(p[0], p[1]);
images[k].setColor(i, j, val);
sum += val / scale;
scale *= alpha;
p[0] *= beta;
p[1] *= beta;
}
img.setColor(i, j, sum);
if (sum > maxval)
maxval = sum;
if (sum < minval)
minval = sum;
}
}
if (norm) {
for (int i = 0; i < img.getWidth(); i++) {
for (int j = 0; j < img.getHeight(); j++) {
float v = img.getColor(i, j).r;
img.setColor(i, j, v/maxval);
// img.setColor(i, j, ofMap(v, 0.0, maxval, 0.0, 1.0));
// img.setColor(i, j, ofMap(v, minval, maxval, 0.0, 1.0));
}
}
}
img.update();
for (ofFloatImage &i : images)
i.update();
dirty = false;
}