I am new to the PImage class, following Daniel Shiffman's Learning Processing PDF.
I am trying to make a sketch where the image pixels are changed according to their neighbours and then updated, then changed again etc. iteratively/cellular automata.
In the sketch below, I load the pixels from the image, go through each one and compare it to it's left neighbour, then say that if the one on the left is less than the current pixel, increase it's brightness.
I think my problem is that when I say updatePixels(), it is not storing this change, it is just displaying it, so when I call loadPixels() it is loading the pixels from the original image again rather than the newly modified one.
Do I need to load the pixels into a 2D array in order to do what I want? what is the simplest way to achieve this kind of feedback effect?
This is the sketch I have made:
PImage img;
void setup() {
size (500, 500);
img = loadImage("pix/12in.jpg");
}
void draw() {
loadPixels();
for (int y = 0; y < img.height; y ++) {
for (int x = 1; x < img.width; x ++) {
int loc = x+ y*img.width;
int locLeft =(x-1)+ y*img.width ;
float gr = brightness(img.pixels[loc]);
if (brightness(img.pixels[loc]) < brightness(img.pixels[locLeft])){
Hello, I have been having a great time learning processing. I am up to a point now where I would like to make use of the data I am creating in processing in other software environments (like blender).
I basically want to export a series of points into a program which can polygonise them.
Unfortunately I am not aware of any free software which can do this and so I cannot even ask which processing library will be able to export the points in an appropriate format.
I was hoping somebody out there would know what direction to point me in.
One way I have tried is to make lines instead of points or triangles and export them using DXF, but this at least doubles my point count and then the kind of software which I am aware of which could read the file is incapable of creating a mesh from this data.
I am having a very strange and counter-intuitive issue, when drawing with point(x , y), if I have the stroke() attribute set to include an alpha value, like stroke(C, 100), or stroke(C,C,C,100) then all of the points are offset to the left and down... I don't understand why! This problem only seems to occur when using point, if I use rect then there is no problem...
float C;
int pX;
int pY;
void setup(){
size (500, 500);
}
void draw(){
C = (C+1)%5;
stroke(C , 200);
pX = int(random(width));
pY = int(random(height));
point(pX, pY);
}
I eventually realised I had to put smooth(); in the void setup(); section, problem solved 6 hours later :D