Script execution
This commit is contained in:
@@ -6,7 +6,7 @@ import java.awt.Rectangle as Rectangle
|
||||
import ch.psi.pshell.imaging.Data as Data
|
||||
|
||||
|
||||
def integrate(ips, roi=None, as_float=True):
|
||||
def integrate(ips, as_float=True):
|
||||
aux = None
|
||||
for i in range(len(ips)):
|
||||
if i==0:
|
||||
@@ -16,22 +16,31 @@ def integrate(ips, roi=None, as_float=True):
|
||||
return aux
|
||||
|
||||
def average (ips, roi=None, as_float=True):
|
||||
aux = integrate(ips, roi, as_float)
|
||||
aux = integrate(ips, as_float)
|
||||
op_const(aux, "divide", float(len(ips)), in_place=True)
|
||||
return aux
|
||||
|
||||
def grab_frames(source, samples, roi=None, wait_next=False):
|
||||
def get_image(source, roi=None, wait_next=False):
|
||||
if wait_next:
|
||||
source.waitNext(-1)
|
||||
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
|
||||
|
||||
def grab_frames(source, samples, roi=None, wait_next=False, sleep=0):
|
||||
frames = []
|
||||
for i in range(samples):
|
||||
aux = get_image(source)
|
||||
if sleep>0:
|
||||
time.sleep(sleep)
|
||||
aux = get_image(source, roi, wait_next)
|
||||
frames.append(aux)
|
||||
return frames
|
||||
|
||||
def average_frames(source, samples = 1, roi=None, as_float=True):
|
||||
return average(grab_frames(source, samples), roi, as_float)
|
||||
def average_frames(source, samples=1, roi=None, wait_next=False, sleep=0, as_float=True):
|
||||
return average(grab_frames(source, samples, roi, wait_next, sleep), as_float)
|
||||
|
||||
def integrate_frames(source, samples = 1, roi=None, as_float=True):
|
||||
return integrate(grab_frames(source, samples), roi, as_float)
|
||||
def integrate_frames(source, samples=1, roi=None, wait_next=False, sleep=0, as_float=True):
|
||||
return integrate(grab_frames(source, samples, roi, wait_next, sleep), as_float)
|
||||
|
||||
|
||||
def get_image_array(ip):
|
||||
if type(av.getProcessor()) == ij.process.FloatProcessor:
|
||||
@@ -39,16 +48,14 @@ def get_image_array(ip):
|
||||
else:
|
||||
return ip.getProcessor().getIntArray()
|
||||
|
||||
def get_image(source, roi=None, wait_next=False):
|
||||
if wait_next:
|
||||
source.waitNext(-1)
|
||||
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
|
||||
|
||||
ret = grab_frames(image, 10)
|
||||
|
||||
ret = grab_frames(image, 10, sleep=0.1)
|
||||
av = average(ret, None, True)
|
||||
print type(av.getProcessor())
|
||||
#db=av.getBufferedImage().getData().getDataBuffer()
|
||||
data = get_image_array(av)
|
||||
plot(data)
|
||||
data
|
||||
|
||||
save_image(av, "{images}/float.tif","tiff")
|
||||
av = average(ret, None, False)
|
||||
save_image(av, "{images}/int.tif","tiff")
|
||||
|
||||
Reference in New Issue
Block a user