I am trying to average 40 images pixel by pixel:
void testApp::setup(){
ofBackground(255,255,255);
processedPixels = new unsigned char[imageIn.width * imageIn.height * 4];
int imageup = 141;
int pixelAverager = 0;
int num = imageIn.width * imageIn.height * 3;
for(int i = 0; i < num; i++){
for(int a = 100; a < imageup; a++){
imageIn.loadImage("signature"+ofToString(a)+".png");
//this points to the the pixels of the loaded image
//ptr can be treated as an array that is the size of the number of bytes in the image.
unsigned char * ptr = imageIn.getPixels();
pixelAverager = pixelAverager + ptr[i];
}
//average the pixels or it wouldn't be a pixelAverager
pixelAverager = pixelAverager / 40;
//first we set our output pixel to black to make sure it is clean to start off with
processedPixels[i] = 0;
//gives the channel's pixel value into output array
processedPixels[i] = pixelAverager;
pixelAverager = 0;
printf ("Characters: %c \n", 'a');
}
imageOut.setFromPixels(processedPixels, imageIn.width, imageIn.height, OF_IMAGE_COLOR);
imageOut.saveImage("averageImage.png");
}
Okay… so first off, to go through 1,920,000 sets of 40 pixels seems like it may take about two months by the method I am doing it (judging by the rate my “Characters: a” message prints to the console). Is there a better way for doing this that won’t require a designated computer?
Secondly, How do I get it to print out my [i] value to the console? The “Characters a” code I stole off some website isn’t going to cut it in the long run.
-Randy