Jak w temacie jestem kompletnym newbie. Program ma za zadanie przejsc pixel za pixelem (kazdy w linii i co 10 wiersz) obrazek i zwrocic do pliku ilosc czerwieni, niebieskiego i zielonego. Problem w tym, ze sam sie nie konczy (nie wiem co jest z petla nie tak) a jesli cos zwraca to jest to zawsze 255 (brak jakichkolwiek zmian, a obrazek bialy nie jest). Pisze to w processing ale utknalem na tym:
PrintWriter output;
void setup()
{
output = createWriter("positions.txt"); //writedown tool enter
size(251,201); // screen size setup
PImage img = loadImage("sharp.jpg"); // implementing image Sketch->Add File
image(img,0,0); // placeing the img on the screen
loadPixels(); // work on pixels
println(width); // chcek total number of pixels width
}
void draw() {
for(int i=0; i < width; i++) { // go pxel by pixel in row
for(int j=0; j < pixels.length/width; j=j+10) // each ten row
{
float r=red(pixels[i]); // read the red value from each chceked pixel
float b=blue(pixels[i]); // read the blue value from each chceked pixel
float g=green(pixels[i]); // read the green value from each chceked pixel
color black=color(0, 0, 0);
set(i, j, black); // checking positions with black color - OK
output.println(r + "," + g + "," + b); // write down the value of red
}
}
}
void keyPressed() {
output.flush(); // Writes the remaining data to the file
output.close(); // Finishes the file
exit(); // Stops the program
}