64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
###################################################################################################
|
|
# Example of using ImageJ functionalities through ijutils.
|
|
###################################################################################################
|
|
|
|
from ijutils import *
|
|
import java.awt.Color as Color
|
|
|
|
import ch.psi.pshell.imaging.Filter as Filter
|
|
from ch.psi.pshell.imaging.Overlays import *
|
|
import ch.psi.pshell.imaging.Pen as Pen
|
|
|
|
|
|
class MyFilter(Filter):
|
|
def process(self, image, data):
|
|
ip = load_image(image)
|
|
(results_puck,output_puck) = detect_pucks(ip)
|
|
(results_samples,output_samples) = detect_samples(ip)
|
|
invert(output_puck)
|
|
invert(output_samples)
|
|
op_image(ip, output_puck, "add")
|
|
op_image(ip, output_samples, "add")
|
|
return ip.getBufferedImage()
|
|
|
|
#Setting the filter to a source
|
|
img.setFilter(MyFilter())
|
|
|
|
|
|
|
|
"""
|
|
#Image Loading
|
|
ip = load_image("{images}/test2.png", title="Image")
|
|
|
|
|
|
|
|
#Puck Detection
|
|
aux = grayscale(ip, in_place=False)
|
|
aux.show()
|
|
plot(get_histogram(aux))
|
|
|
|
subtract_background(aux)
|
|
threshold(aux,0,50); aux.repaintWindow()
|
|
binary_fill_holes(aux); aux.repaintWindow()
|
|
(results,output_img)=analyse_particles(aux, 10000,50000,
|
|
fill_holes = False, exclude_edges = True,print_table=True,
|
|
output_image = "outlines", minCirc = 0.0, maxCirc = 1.0)
|
|
output_img.show()
|
|
|
|
|
|
#Sample detection
|
|
aux = grayscale(ip, in_place=False)
|
|
aux.show()
|
|
|
|
invert(aux); aux.repaintWindow()
|
|
#gaussian_blur(aux); aux.repaintWindow()
|
|
subtract_background(aux); aux.repaintWindow()
|
|
auto_threshold(aux); aux.repaintWindow()
|
|
binary_open(aux); aux.repaintWindow()
|
|
#binary_fill_holes(aux); aux.repaintWindow()
|
|
(results,output_img)=analyse_particles(aux, 250,1000,
|
|
fill_holes = False, exclude_edges = True,print_table=True,
|
|
output_image = "outlines", minCirc = 0.7, maxCirc = 1.0)
|
|
output_img.show()
|
|
|
|
""" |