Pixel Sorting with threshold

Hi. I’m new to Processing. Hope someone is able to help me.

In my sketch the pixel sorting work on width, but I I need it to be vertical non horizontal … how?

Thank you.

This is the code:

int mode = 0;

int threshold;

PImage img;

String fileType = “jpg”;

void setup() {

img = loadImage(“Tree.jpg”);
size(1200, 675);
image(img, width, height);
frameRate(60);

}

void draw() {
img.loadPixels();

for (int k=height; k<height*width; k++) {
if (threshold < 150000) {
if (brightness(img.pixels[k]) > threshold) {
img.pixels[k] = color(
int(red(img.pixels[height])),
int(green(img.pixels[height])),
int(blue(img.pixels[height])));
}

  else {
    img.pixels[height] = color(
    int(red(img.pixels[k-1])),
    int(green(img.pixels[k-1])),
    int(blue(img.pixels[k-1])));
  }
  threshold = threshold+10;
}

  else {
  threshold = 0;
}

}

img.updatePixels();
image(img, 0, 0);
}

Hi @Alexx
I changed the quotation marks around the strings but then I get a problem with

    if (threshold < 150000) { //150000
      if (brightness(img.pixels[k]) > threshold) {

This throws up: ArrayIndexOutOfBoundsException: 270000 Probably because threshold is not given a value (other than zero).

Do you want to isolate each vertical line of pixels in your image and then sort their positions based on brightness? If so, you might this helpful: https://processing.org/tutorials/pixels/

The tutorial includes this example http://learningprocessing.com/examples/chp15/example-15-08-Brightness