libtthimage/Lib/detect2.c

48 lines
838 B
C
Raw Normal View History

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