example6.py
- See also:
- example6.c
import time
from fulguro import *
def benchmark(function,nbiter,*args):
t=time.time()
for i in range(nbiter):
function(*args)
t2=time.time()
return ((t2-t)*1000)/nbiter
def getNhbMin(result,extr):
flgr2d_get_nhb_minimum(result,extr)
imin = flgr2d_load_pgm('../../images/gray/lena.pgm')
imout1 = FLGR_Data2D(imin)
imout2 = FLGR_Data2D(imin)
nhb1 = FLGR_Data2D(3,3,imin.spp,imin.type,FLGR_RECT,FLGR_8_CONNEX)
flgr2d_data_set_shape(nhb1,FLGR_USER_SHAPE)
speed = benchmark(flgr2d_erode,10,imout1,imin,nhb1)
print 'C layer neighborhood operation speed: ',speed,'ms'
speed = benchmark(flgr2d_raster_slide_window,1,imout2,imin,nhb1,FLGR_NHB_NO_SYM,getNhbMin)
print 'Python layer neighborhood operation speed: ',speed,'ms'
flgr_display(imout1,'erode',
imout2,'erode_user_filter')