Files
x04sa-es3/script/cpython/image_functions.py
gac-x04sa 532e93e8b9 Startup
2018-10-30 16:10:29 +01:00

18 lines
748 B
Python

import numpy
def img_get_int(fname, header, width, height, depth, x1,y1,x2,y2, bx1,by1,bx2,by2 ):
# read actual image file
img = numpy.fromfile(fname, dtype=numpy.uint32)
img.shape = height, width
# signal roi
area_I = ( x2 - x1 + 1) * ( y2 - y1 + 1)
I_sum = img[y1:y2, x1:x2].sum()
thresh1_count = len(numpy.where(img>thres1)[0])
thresh2_count = len(numpy.where(img>thres2)[0])
thresh3_count = len(numpy.where(img>thres3)[0])
thresh4_count = len(numpy.where(img>thres4)[0])
# background roi
I_sum_bgr = img[by1:by2, bx1:bx2].sum()
area_bgr= (bx2 - bx1 + 1) * (by2 - by1 + 1)
return (I_sum, area_I, thresh1_count, thresh2_count, thresh3_count, thresh4_count, I_sum_bgr, area_bgr)