libtthimage/Lib/detect2.c

48 lines
838 B
C
Raw Normal View History

2022-06-26 20:06:35 +11:00
/*
detect2.c
---------
*/
#include <stdio.h>
2022-07-07 21:52:00 +11:00
#include "../tthimage.h"
2022-06-26 20:06:35 +11:00
/*::------------------------------------------------------------------::*/
/*
* 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;
2022-07-07 21:52:00 +11:00
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %p )\n", __func__, img, seuilr, ptl);
#endif
2022-06-26 20:06:35 +11:00
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;
}
/*::------------------------------------------------------------------::*/