// // EFP_Average.C // // $Id: EFP_Average.C,v 1.4 1998/10/14 21:25:55 mmp Exp $ // /* A simple plug-in that returns the image that is an average of two input images */ #include "EF.h" #include #include extern "C" { void averageImages(EF_Image *image, EF_Image *im, EF_Image *outim, float); void pluginInit(EF_PluginOptions *options); } /* This is called when the plug-in is loaded by the video editor. We register the plug-in with the editor by filling in the options structure */ void pluginInit(EF_PluginOptions *options) { options->applyTwo = averageImages; strcpy(options->name,"Average"); } void averageImages(EF_Image *image1, EF_Image *image2, EF_Image *result, float) { /* Loop over all of the pixels in each image */ for(int y = 0; y < image1->ySize; y++) { for (int x = 0; x < image1->xSize; x++) { /* Get the pixel from each image */ long pix1 = EF_ImageXY(image1, x, y); long pix2 = EF_ImageXY(image2, x, y); long pixAvg; /* Compute the average of each component */ RED(pixAvg) = (RED(pix1) + RED(pix2)) / 2; GREEN(pixAvg) = (GREEN(pix1) + GREEN(pix2)) / 2; BLUE(pixAvg) = (BLUE(pix1) + BLUE(pix2)) / 2; ALPHA(pixAvg) = (ALPHA(pix1) + ALPHA(pix2)) / 2; /* Set the corresponding pixel in the result image with the average pixel */ EF_ImageXY(result, x, y)= pixAvg; } } }