Script execution
This commit is contained in:
+30
-23
@@ -6,7 +6,7 @@ import java.awt.Rectangle as Rectangle
|
|||||||
import ch.psi.pshell.imaging.Data as Data
|
import ch.psi.pshell.imaging.Data as Data
|
||||||
|
|
||||||
|
|
||||||
def integrate(ips, roi=None, as_float=True):
|
def integrate(ips, as_float=True):
|
||||||
aux = None
|
aux = None
|
||||||
for i in range(len(ips)):
|
for i in range(len(ips)):
|
||||||
if i==0:
|
if i==0:
|
||||||
@@ -16,39 +16,46 @@ def integrate(ips, roi=None, as_float=True):
|
|||||||
return aux
|
return aux
|
||||||
|
|
||||||
def average (ips, roi=None, as_float=True):
|
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)
|
op_const(aux, "divide", float(len(ips)), in_place=True)
|
||||||
return aux
|
return aux
|
||||||
|
|
||||||
def grab_frames(source, samples, roi=None, wait_next=False):
|
|
||||||
frames = []
|
|
||||||
for i in range(samples):
|
|
||||||
aux = get_image(source)
|
|
||||||
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 integrate_frames(source, samples = 1, roi=None, as_float=True):
|
|
||||||
return integrate(grab_frames(source, samples), roi, as_float)
|
|
||||||
|
|
||||||
def get_image_array(ip):
|
|
||||||
if type(av.getProcessor()) == ij.process.FloatProcessor:
|
|
||||||
return ip.getProcessor().getFloatArray()
|
|
||||||
else:
|
|
||||||
return ip.getProcessor().getIntArray()
|
|
||||||
|
|
||||||
def get_image(source, roi=None, wait_next=False):
|
def get_image(source, roi=None, wait_next=False):
|
||||||
if wait_next:
|
if wait_next:
|
||||||
source.waitNext(-1)
|
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))
|
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
|
return ret
|
||||||
|
|
||||||
ret = grab_frames(image, 10)
|
def grab_frames(source, samples, roi=None, wait_next=False, sleep=0):
|
||||||
|
frames = []
|
||||||
|
for i in range(samples):
|
||||||
|
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, 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, 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:
|
||||||
|
return ip.getProcessor().getFloatArray()
|
||||||
|
else:
|
||||||
|
return ip.getProcessor().getIntArray()
|
||||||
|
|
||||||
|
|
||||||
|
ret = grab_frames(image, 10, sleep=0.1)
|
||||||
av = average(ret, None, True)
|
av = average(ret, None, True)
|
||||||
print type(av.getProcessor())
|
print type(av.getProcessor())
|
||||||
#db=av.getBufferedImage().getData().getDataBuffer()
|
#db=av.getBufferedImage().getData().getDataBuffer()
|
||||||
data = get_image_array(av)
|
data = get_image_array(av)
|
||||||
plot(data)
|
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