reading values from a buffer
in
Programming Questions
•
1 year ago
hi,
i am trying to read brightness values from a buffer. there is data in the image, but when i try to print the values, i get 0.0 for all pixels. i have a second buffer for which the values are reading. (i have found that there is a much better and shorter way to do this, but i am curious as to why the values aren't registering.)
here is the code:
PGraphics noisePlane;
PGraphics noiseSignal;
PGraphics crossFader;
float noiseScale = 0.02;
float noiseFeatureBrightnessSignal;
void setup()
{
size(500, 500, P3D);
noisePlane = createGraphics(width/2, height, P3D);
noiseSignal = createGraphics(width, height, P3D);
crossFader = createGraphics(width, height, P3D);
for(int x = 0; x <= width; x ++)
{
for(int y = 0; y <= height; y ++)
{
float noisePlaneValNoiseSignal = noise(x * noiseScale, y * noiseScale);
noisePlane.beginDraw();
noisePlane.stroke(noisePlaneValNoiseSignal * 255);
noisePlane.point(x, y);
noisePlane.endDraw();
}
}
for(int i = 0; i <= 1000; i ++)
{
for(int j = 0; j <= 1000; j ++)
{
float crossFaderValNoiseSignal = noise(i * noiseScale, j * noiseScale);
crossFader.beginDraw();
crossFader.stroke(crossFaderValNoiseSignal * 255);
crossFader.point(i, j);
crossFader.endDraw();
}
}
// image(crossFader, 0, 0);
noiseSignal.beginDraw();
image(noisePlane, 0, 0);
pushMatrix();
translate(width, 0);
rotateY(PI);
image(noisePlane, 0, 0);
popMatrix();
noiseSignal.endDraw();
image(noiseSignal, 0, 0);
}
void draw()
{
noiseSignal.loadPixels();
for(int x = 0; x <= width - 1; x ++)
{
for(int y = 0; y <= height - 1; y ++)
{
float value = brightness(noiseSignal.pixels[x + width * y]);
println(value);
}
}
thanks,
destro
i am trying to read brightness values from a buffer. there is data in the image, but when i try to print the values, i get 0.0 for all pixels. i have a second buffer for which the values are reading. (i have found that there is a much better and shorter way to do this, but i am curious as to why the values aren't registering.)
here is the code:
PGraphics noisePlane;
PGraphics noiseSignal;
PGraphics crossFader;
float noiseScale = 0.02;
float noiseFeatureBrightnessSignal;
void setup()
{
size(500, 500, P3D);
noisePlane = createGraphics(width/2, height, P3D);
noiseSignal = createGraphics(width, height, P3D);
crossFader = createGraphics(width, height, P3D);
for(int x = 0; x <= width; x ++)
{
for(int y = 0; y <= height; y ++)
{
float noisePlaneValNoiseSignal = noise(x * noiseScale, y * noiseScale);
noisePlane.beginDraw();
noisePlane.stroke(noisePlaneValNoiseSignal * 255);
noisePlane.point(x, y);
noisePlane.endDraw();
}
}
for(int i = 0; i <= 1000; i ++)
{
for(int j = 0; j <= 1000; j ++)
{
float crossFaderValNoiseSignal = noise(i * noiseScale, j * noiseScale);
crossFader.beginDraw();
crossFader.stroke(crossFaderValNoiseSignal * 255);
crossFader.point(i, j);
crossFader.endDraw();
}
}
// image(crossFader, 0, 0);
noiseSignal.beginDraw();
image(noisePlane, 0, 0);
pushMatrix();
translate(width, 0);
rotateY(PI);
image(noisePlane, 0, 0);
popMatrix();
noiseSignal.endDraw();
image(noiseSignal, 0, 0);
}
void draw()
{
noiseSignal.loadPixels();
for(int x = 0; x <= width - 1; x ++)
{
for(int y = 0; y <= height - 1; y ++)
{
float value = brightness(noiseSignal.pixels[x + width * y]);
println(value);
}
}
thanks,
destro
1