Exemple #1
0
fopen.restype = ctypes.POINTER(Wlz.FILE)

f = 'test.wlz'

print('Read test object from the file ' +  f);
fp = fopen(f, 'rb')
obj = Wlz.WlzAssignObject(Wlz.WlzReadObj(fp, ctypes.byref(errNum)), None)
fclose(fp)
if(bool(errNum)):
  print('Failed to read object from ' + f + \
        ' (' + Wlz.WlzStringFromErrorNum(errNum, None) + ').')
  exit(1)


if((not bool(obj.contents)) or
   ((obj.contents.type != Wlz.WlzObjectType(Wlz.WLZ_3D_DOMAINOBJ).value) and
    (obj.contents.type != Wlz.WlzObjectType(Wlz.WLZ_2D_DOMAINOBJ).value))): 
  print('Either 2 or 3D domain object with values required.')
  exit(1)

print('Computing histogram')
hobj = Wlz.WlzAssignObject( \
       Wlz.WlzHistogramObj(obj, \
               ctypes.c_int(0), ctypes.c_double(0.0), ctypes.c_double(1.0), \
				       ctypes.byref(errNum)), None)
if(bool(errNum)):
  print('Failed to compute histogram ' + \
        '(' + Wlz.WlzStringFromErrorNum(errNum, None) + ').')
  exit(1)
  
print('Plotting histogram')