I would like to take two images (well.. one plus a copy of itself) and copy rows from one onto the other. The reason I am doing this is to rearrange the rows in the original image. I keep a copy to get the row data from so I am not overwriting the data I need as I go along.
I suppose I don't need to be overwriting the original. I could create a new image, but how would I do that row by row like this? And there is no particular order in which the rows will be combined.
What I don't understand, is how do I have two images in memory at once and how do I access there data individually? I was using the pixels[] array and get() to gather my data. Then I wondered how get() knows which image I want to GET pixels from. Is this a silly question?
I have a formal education with C, but this sort of confusion I always run into with Processing makes me very frustrated with it. Maybe it's just OOP that I don't get. I have been using Processing since 2007.
Here is a function I use to average the green value in all rows and return an array of those averages. This is tested and works.
float[] rowAvgs(PImage img)
{
float totalGreen = 0;
float[] average = new float[img.height]; //Array to hold results
for(int j = 0; j < img.height; j++) //Rows
{
for(int i = 0; i < img.width; i++) //Columns
{
totalGreen += green(get(i, j)); //Running total
}
average[j] = totalGreen / img.width; //average of j-eth row
totalGreen = 0; //Reset total to 0
}
return average;
}
I originally wanted to take the average of the color (RGB) of a row, but quickly got confused on how to do that also. So I am just picking a color instead
This is my first post here so bear with me.. I would say I am slightly above newbie-level with Processing, but not by much. I have done a few neat and rather complex projects using Processing before, but I am no expert.
My current problem involves working with files that are too inconvenient to move into the "data" directory of my sketch. I want to work with some 'log' files and I don't want to move them. Is there any way at all that I can access them with Processing--perhaps using a complete file-path or something? The particular function I am using is "loadStrings()". Any advice would be greatly appreciated. This is the only thing preventing my project from being flexible and easy to work with.