example9.py
- See also:
- example9.c
from fulguro import *
imin = flgr2d_load_png("../../images/color/lena.png");
imin2 = flgr2d_load_pgm("../../images/gray/lena.pgm");
imout = FLGR_Data2D(imin)
imout_ref = FLGR_Data2D(imin)
semap8 = FLGR_Data2D(imin2)
semap = FLGR_Data2D(imin.size_y, imin.size_x, 1, FLGR_INT32)
semaptmp = FLGR_Data2D(imin.size_y, imin.size_x, 1, FLGR_INT32)
nhbsemap = FLGR_Data2D(1,FLGR_INT32, FLGR_8_CONNEX)
vecmax = FLGR_Vector(1,FLGR_INT32)
vecmin = FLGR_Vector(1,FLGR_INT32)
flgr2d_copy(semaptmp,imin2)
flgr2d_gradient_thick(semap,semaptmp,nhbsemap)
flgr2d_arith_invert(semap,semap)
flgr2d_histogram_normalize(semap,semap,0,255)
flgr2d_arith_div(semap,semap,32)
flgr2d_copy(semap8,semap)
flgr2d_measure_min_max(semap,vecmin,vecmax)
w = vecmax[0];
w = (w/2)*2+1
nhb_ref = FLGR_Data2D(w, w, imin.spp, imin.type, FLGR_RECT,FLGR_8_CONNEX)
print "Maximum median size :", w
flgr2d_median_resizeable(imout,imin,semap,FLGR_DISC)
flgr2d_median(imout_ref,imin,nhb_ref);
flgr_display(imin,imout_ref,imout,semap8,"in","out_ref","out","map")