Script execution
This commit is contained in:
@@ -22,6 +22,9 @@ def detect_led(ip):
|
||||
|
||||
roi_center = (2322, 1025)
|
||||
roi_radius = 1000
|
||||
integrations = 10
|
||||
frames = []
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -67,17 +70,34 @@ def in_roi(x,y):
|
||||
return math.hypot(x-roi_radius, y-roi_radius) < roi_radius
|
||||
|
||||
|
||||
def detect_led(ip):
|
||||
def integrate (ips):
|
||||
for i in range(len(ips)):
|
||||
if i==0:
|
||||
aux = new_image(2* roi_radius, 2*roi_radius, image_type="float", title = "sum", fill_color = None)
|
||||
op_image(aux, ips[i], "add", float_result=True, in_place=True)
|
||||
op_const(aux, "divide", len(ips), in_place=True)
|
||||
return aux
|
||||
|
||||
|
||||
def detect_led(ip, integrations):
|
||||
global roi_center, roi_radius
|
||||
aux = sub_image(ip, roi_center[0] - roi_radius, roi_center[1] - roi_radius, 2* roi_radius, 2*roi_radius)
|
||||
grayscale(aux)
|
||||
|
||||
if (integrations>1):
|
||||
frames.append(aux)
|
||||
if len(frames) >integrations:
|
||||
del frames[0]
|
||||
aux = integrate(frames)
|
||||
|
||||
#aux = get_channel(aux, "blue")
|
||||
invert(aux)
|
||||
#subtract_background(aux)
|
||||
auto_threshold(aux)
|
||||
binary_open(aux)
|
||||
(results,output) = analyse_particles(aux, 800,4000,
|
||||
#binary_open(aux)
|
||||
(results,output) = analyse_particles(aux, 400,4000,
|
||||
fill_holes = True, exclude_edges = True,print_table=False,
|
||||
output_image = "outlines", minCirc = 0.4
|
||||
output_image = "outlines", minCirc = 0.2
|
||||
, maxCirc = 1.0)
|
||||
r=results
|
||||
|
||||
@@ -89,23 +109,23 @@ def detect_led(ip):
|
||||
else:
|
||||
#print >> sys.stderr, 'Invalid location:' + str(r.getValue("XM", row)) + ", " + str( r.getValue("YM", row))
|
||||
print >> sys.stderr, r.getRowAsString(row)
|
||||
|
||||
#return (results,aux)
|
||||
return (results,output)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class MyFilter(Filter):
|
||||
def process(self, image, data):
|
||||
global roi_center, roi_radius
|
||||
ip = load_image(image)
|
||||
(results,output) = detect_led(ip)
|
||||
global roi_center, roi_radius, frames, integrations
|
||||
ip = load_image(image)
|
||||
(results,output) = detect_led(ip, integrations)
|
||||
invert(output)
|
||||
#set_lut(output, outline_lut1[0], outline_lut1[1], outline_lut1[2])
|
||||
#op_image(ip, output, "and")
|
||||
output = pad_image(output, roi_center[0] - roi_radius, 0, roi_center[1] - roi_radius, 0)
|
||||
|
||||
output = pad_image(output, roi_center[0] - roi_radius, 0, roi_center[1] - roi_radius, 0)
|
||||
op_image(ip, output, "xor")
|
||||
return ip.getBufferedImage()
|
||||
#return output.getBufferedImage()
|
||||
|
||||
#Setting the filter to a source
|
||||
img.setFilter(MyFilter())
|
||||
|
||||
Reference in New Issue
Block a user