libtthimage/Lib/pov_hf15e.c

88 lines
2.0 KiB
C
Raw Normal View History

2022-06-27 09:48:18 +11:00
/*
pov_hf15e.c
===========
2024-08-11 20:21:23 +11:00
operations de morphologie mathematique appliquees
2022-06-27 09:48:18 +11:00
aux height-fields.
*/
#include <stdio.h>
#include <stdlib.h>
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
static struct
{
int x, y;
} off[] =
{
2024-08-11 20:21:23 +11:00
{ -1, -1 }, { 0, -1 }, { 1, -1 },
{ -1, 0 }, { 0, 0 }, { 1, 0 },
{ -1, 1 }, { 0, 1 }, { 1, 1 }
2022-06-27 09:48:18 +11:00
};
/*::------------------------------------------------------------------::*/
/*
2024-08-11 20:21:23 +11:00
* le parametre 'coef' n'est pas utilise. D'ailleurs, je ne vois
2022-06-27 09:48:18 +11:00
* pas trop quoi y mettre ?
*/
2024-08-11 20:21:23 +11:00
int Image_hf15_dilate(Image_Desc *src, Image_Desc *dst, int coef)
2022-06-27 09:48:18 +11:00
{
2024-08-11 20:21:23 +11:00
(void)coef; /* KILL WARNING */
2022-06-27 09:48:18 +11:00
int foo;
int x, y, h, hmax;
2024-08-11 20:21:23 +11:00
if ( (foo=Image_compare_desc(src, dst)) ) {
2022-06-27 09:48:18 +11:00
fprintf(stderr, "Image hf15 dilate: images differents %d\n", foo);
return foo;
}
2024-08-11 20:21:23 +11:00
for (y=1; y<dst->height-1; y++) {
for (x=1; x<dst->width-1; x++) {
2022-06-27 09:48:18 +11:00
hmax = -1664;
2024-08-11 20:21:23 +11:00
for (foo=0; foo<9; foo++) {
2022-06-27 09:48:18 +11:00
h = Image_hf15_height(src, x+off[foo].x, y+off[foo].y);
if (h > hmax) hmax = h;
}
Image_hf15_plot(dst, x, y, hmax);
}
}
return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/*
2024-08-11 20:21:23 +11:00
* le parametre 'coef' n'est pas utilise.
2022-06-27 09:48:18 +11:00
*/
2024-08-11 20:21:23 +11:00
int Image_hf15_erode(Image_Desc *src, Image_Desc *dst, int coef)
2022-06-27 09:48:18 +11:00
{
2024-08-11 20:21:23 +11:00
(void)coef; /* KILL WARNING */
2022-06-27 09:48:18 +11:00
int foo;
int x, y, h, hmin;
2024-08-11 20:21:23 +11:00
if ( (foo=Image_compare_desc(src, dst)) ) {
2022-06-27 09:48:18 +11:00
fprintf(stderr, "Image hf15 erode: images differents %d\n", foo);
return foo;
}
2024-08-11 20:21:23 +11:00
for (y=1; y<dst->height-1; y++) {
for (x=1; x<dst->width-1; x++) {
2022-06-27 09:48:18 +11:00
hmin = 42042;
2024-08-11 20:21:23 +11:00
for (foo=0; foo<9; foo++) {
2022-06-27 09:48:18 +11:00
h = Image_hf15_height(src, x+off[foo].x, y+off[foo].y);
if (h < hmin) hmin = h;
}
Image_hf15_plot(dst, x, y, hmin);
}
}
return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/*
2024-08-11 20:21:23 +11:00
* Et maintenant, il reste a coder le chapeau haut-de-forme
2022-06-27 09:48:18 +11:00
*/
/*::------------------------------------------------------------------::*/