run("pip")

ip1_orig = load_image("{data}/img/img1.png")

ip1_grayscale = ip1_orig.duplicate()
grayscale(ip1_grayscale) 

pr1 = ip1_grayscale.getProcessor()

#ip1_grayscale.show()


ip1_max = find_maxima(ip1_grayscale, 50, output_type=MaximumFinder.SINGLE_POINTS)
#ip1_max.show()
(x,y) =  get_maxima_points(ip1_grayscale,50)
p=plot(x, xdata=Convert.toDouble(y))[0]
p.getSeries(0).setPointSize(5)
p.getSeries(0).setLinesVisible(False)

"""
f = image_fft(ip1_grayscale, False)
#f.getProcessor().fillOval(50,50, 50, 50)
#f.getProcessor().fillOval(250,250, 50, 50)
i = image_ffti(f, False)
#f.show()
#i.show()

"""



#bandpass_filter(ip1_grayscale,0, 5)
#ip1_grayscale.show()
#edges(ip1_grayscale)

#bandpass_filter(ip1,20,40)
#ip1.show()
ip_bin = ip1_grayscale.duplicate()
threshold(ip_bin, 80, 255)
#binary_skeletonize(ip_bin)


#enhance_contrast(ip1_grayscale)
op_rank (ip1_grayscale, "max", kernel_radius = 1.0)

ip1_grayscale.show()
ip_bin.show()