/*********************************************************************** * Fulguro Example 6 : User defined neighborhood operations ***********************************************************************/ #include <flgrCoreTypes.h> #include <flgrCoreErrors.h> #include <flgrCoreData.h> #include <flgrCoreIO.h> #include <flgrCoreSlideWindow.h> #include <flgrCoreNhbManage.h> #include <flgrArith.h> #include <flgrImageIO.h> #include <flgrMorphoBase.h> void flgr2d_my_maximum_fgUINT8(FLGR_Vector *result, FLGR_NhbBox2D *extr) { int i,k; int spp = extr->spp; fgUINT8 *presult = (fgUINT8 *) result->array; fgUINT8 *list_data_val; int *size = extr->size; fgUINT8 maxi; for(k=0 ; k<spp ; k++) { list_data_val = (fgUINT8 *) extr->list_data_val[k]; maxi = list_data_val[0]; for(i=1 ; i<size[k] ; i++){ maxi = FLGR_MAX(maxi,list_data_val[i]); } flgr_set_array_fgUINT8(presult,k,maxi); } return; } void flgr2d_my_dilate_fgUINT8(FLGR_Data2D *imgdest, FLGR_Data2D *imgsrc, FLGR_Data2D *nhb) { flgr2d_raster_slide_window(imgdest, imgsrc, nhb, FLGR_NHB_NO_SYM, flgr2d_my_maximum_fgUINT8); } int main(void) { FLGR_Data2D *imin; FLGR_Data2D *imDest1, *imDest2, *imtmp; FLGR_Data2D *nhb; int i; imin = flgr2d_load_pgm("../../images/gray/lena.pgm"); imDest1 = flgr2d_create_pixmap_from(imin); nhb = flgr2d_create_neighborhood(13,13,imin->spp,imin->type,FLGR_HEX,FLGR_6_CONNEX); flgr2d_my_dilate_fgUINT8(imDest1, imin, nhb); flgr2d_save_pgm(imDest1,"my_dilate_uint8.pgm",5); flgr2d_destroy(imin); flgr2d_destroy(imDest1); flgr2d_destroy(nhb); }