Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

How to extract pictrure 0-255 value in a matrix

edited December 2016

Hi, I want to extract the luminosity value of the pixels of greyscale images as a matrix in a .txt file, process them mathematicaly in a suitable program (e.g excel) and recombine them in a new image. I'm totaly ignorant about programming so any help would be of great help. Thanks

Tagged:

look here:

https://www.processing.org/reference/PImage_pixels.html

When you got this:

This code is supposed to read a file:

``````PImage tower;

void setup() {
size(600, 200);
int dimension = tower.width * tower.height;
String[] ca1  = new String [dimension];
for (int i = 0; i < dimension; i++) {
color c1 = tower.pixels[i];

ca1[i] = str( brightness(c1)) ;

//ca1[i] = red(c1)+","
//  +green(c1)+","
//  +blue(c1);
}
// tower.updatePixels();
saveStrings("text1.csv", ca1);
}

void draw() {
image(tower, 0, 0);
}
``````

See also `get()` in the reference.

Re:

process them mathematicaly in a suitable program (e.g excel)

This is (probably) a really bad idea. It is much, much easier (and faster, and more reliable) to mathematically process matrices of pixels using the Processing language, rather than exporting them to Excel, doing math on them, then reimporting them.

If you provide details of your calculations on your brightness and how it will be recombined with your original image, it could be implemented here on chrisir's code. Just give it a try!

Kf