libtthimage/Lib/detect2.c
2022-06-26 12:22:12 +02:00

44 lines
741 B
C

/*
detect2.c
---------
*/
#include <stdio.h>
#include "tthimage.h"
/*::------------------------------------------------------------------::*/
/*
* Warning: this function can be very expensive in memory use
*/
int
Image_pix2ptl(Image_Desc *img, int seuil, Image_PtList *ptl)
{
int foo, val;
int x, y;
long nbre;
nbre = 0;
for (y=0; y<img->height; y++)
{
for (x=0; x<img->width; x++)
{
val = Image_R_pixel(img, x, y);
if (val > seuil)
{
Image_ptl_add(ptl, x, y, val, 0);
nbre++;
}
}
}
foo = Image_ptl_write("pixels.ptl", ptl);
#if DEBUG_LEVEL
fprintf(stderr, "pix2ptl: %ld pixels\n", nbre);
#endif
return FUNC_IS_ALPHA;
}
/*::------------------------------------------------------------------::*/