diff --git a/script/utils.py b/script/utils.py index e69de29..62c0494 100644 --- a/script/utils.py +++ b/script/utils.py @@ -0,0 +1,37 @@ +from ijutils import * +from ch.psi.pshell.imaging.Overlays import * +import ch.psi.pshell.imaging.Pen as Pen +import java.awt.Rectangle as Rectangle + + +def integrate(ips, roi=None): + aux = None + for i in range(len(ips)): + if i==0: + aux = new_image(ips[i].width, ips[i].height, image_type="float", title = "sum", fill_color = None) + op_image(aux, ips[i], "add", float_result=True, in_place=True) + return aux + +def average (ips): + aux = integrate(ips) + op_const(aux, "divide", len(ips), in_place=True) + return aux + +def grab_frames(source, samples): + frames = [] + for i in range(samples): + aux = get_image(source) + frames.append(aux) + return frames + +def average_frames(source, samples = 1): + return average(grab_frames(source, samples)) + +def integrate_frames(source, samples = 1): + return integrate(grab_frames(source, samples)) + +def get_image(source, roi=None): + ret = load_image(Utils.grayscale(source.output, Rectangle(roi[0], roi[1], roi[2], roi[3]) if (roi is not None) else None)) + return ret + +