Script execution

This commit is contained in:
gac-S_Changer
2016-11-17 10:16:54 +01:00
parent b4861a58b0
commit b1eda4692a

View File

@@ -20,24 +20,46 @@ def detect_led(ip):
output_image = "outlines", minCirc = 0.4, maxCirc = 1.0)
"""
roi_center = (2322, 1025)
roi_radius = 1000
def in_roi(x,y):
global roi_center, roi_radius
return math.hypot(x-roi_center[0], y-roi_center[1]) < roi_radius
r=None
def detect_led(ip):
global r
aux = grayscale(ip, in_place=False)
invert(aux)
#subtract_background(aux)
auto_threshold(aux)
binary_open(aux)
return analyse_particles(aux, 900,2500,
fill_holes = True, exclude_edges = True,print_table=True,
(results,output) = analyse_particles(aux, 800,4000,
fill_holes = True, exclude_edges = True,print_table=False,
output_image = "outlines", minCirc = 0.4
, maxCirc = 1.0)
r=results
print rt.getColumnHeadings()
for row in range (rt.counter):
if in_roi(r.getValue("XM",row), r.getValue("YM",row)):
print rt.getRowAsString(row)
else:
print >> sys.stderr, 'Invalid location:' + str(r.getValue("XM", row), r.getValue("YM", row)
return (results,output)
class MyFilter(Filter):
def process(self, image, data):
ip = load_image(image)
(results,output) = detect_led(ip)
invert(output)
#set_lut(output, outline_lut1[0], outline_lut1[1], outline_lut1[2])
op_image(ip, output, "and")
#op_image(ip, output, "and")
op_image(ip, output, "xor")
return ip.getBufferedImage()
#return output.getBufferedImage()