From 6b62017f34eaabab31444d8e5b0d7b15f19e7d52 Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Fri, 23 Jun 2017 14:30:57 +0200 Subject: [PATCH] Script execution --- script/CoverDetection.py | 53 ++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/script/CoverDetection.py b/script/CoverDetection.py index b843ce4..e047c3e 100644 --- a/script/CoverDetection.py +++ b/script/CoverDetection.py @@ -1,32 +1,69 @@ ################################################################################################### # Procedure to detect the cover orientation ################################################################################################### - +import ch.psi.pshell.imaging.Utils.integrateVertically as integrateVertically img.backgroundEnabled=False - line = load_image("{images}/line.png", title="Line") +line.getProcessor().setBackgroundValue(0.0) - +#renderer = show_panel(line.bufferedImage) ip = get_image() + + smooth(ip) -#bandpass_filter(ip, 10, 1000) +#bandpass_filter(ip, 30, 1000) edges(ip) -invert(ip) +#invert(ip) +#auto_threshold(ip, method = "Default") + + +#auto_threshold(ip, method = "Li") auto_threshold(ip, method = "MaxEntropy") +""" +for m in AutoThresholder.getMethods(): + print m + aux = ip.duplicate() + auto_threshold(aux, method = m) + binary_fill_holes(aux, dark_background=False) + renderer = show_panel(aux.bufferedImage) + time.sleep(1.0) +""" +#binary_fill_holes(ip, dark_background=True) +#binary_fill_holes(ip, dark_background=False) +#binary_open(ip, dark_background=Tr) -#binary_erode(ip, dark_background=True) renderer = show_panel(ip.bufferedImage) -op = op_fft(ip, line, "correlate") -renderer = show_panel(op.bufferedImage) + + + +line = sub_image(line, 89, 89, 1024, 1024) +ip = sub_image(ip, 89, 89, 1024, 1024) +#op = op_fft(ip, line, "correlate") + +#renderer = show_panel(op.bufferedImage) +#line.show() + +vals = [] +for i in range (180): + l = line.duplicate() + l.getProcessor().setBackgroundValue(0.0) + l.getProcessor().rotate(float(i)) + op = op_fft(ip, l, "correlate") + bi = op.getBufferedImage() + p = integrateVertically(bi) + vals.append(sum(p)) + + #renderer = show_panel(op.bufferedImage) + #time.sleep(0.001) #image_fft(ip)