#include "ninox.h" struct HotPixel { int x,y; int count; }; static int Frames = 0; static struct HotPixel *List; static int nHotPixels = 0; static int AddToList(int x,int y); // define hot pixels to be pixels that are more than 50 percent brighter than // all their 8 neighbors on all frames (ie they don't move) int do_DetectHotPixels(struct Image *img) { int x,y; int width = img->width; int height = img->height; int depth = img->depth; unsigned char *data = (unsigned char *)img->data; unsigned short *udata = (unsigned short *)img->data; int threshhold = 200; ++Frames; switch(depth) { case 8: for(y=1; y threshhold && ( data[o-width-1]< threshhold && data[o-width]< threshhold && data[o-width+1]< threshhold && data[o-1]< threshhold && data[o+1]< threshhold && data[o+width-1]< threshhold && data[o+width]< threshhold && data[o+width+1]< threshhold)) AddToList(x,y); } } break; case 16: threshhold <<= 8; for(y=1; y threshhold && ( udata[o-width-1]< threshhold && udata[o-width]< threshhold && udata[o-width+1]< threshhold && udata[o-1]< threshhold && udata[o+1]< threshhold && udata[o+width-1]< threshhold && udata[o+width]< threshhold && udata[o+width+1]< threshhold)) AddToList(x,y); } } break; default: printf("DetectHotPixels: Depth %d not supported\n",depth); break; } return 1; } static int AddToList(int x,int y) { int n; if (! nHotPixels) { nHotPixels = 32; List = (struct HotPixel *) ZeroMalloc(nHotPixels * sizeof(struct HotPixel)); } for(n=0; n0 && List[i].y>0; ++i) { if (List[i].count == Frames) fprintf(z,"%d %d\n",List[i].x,List[i].y); } fclose(z); return 0; }