Startup
This commit is contained in:
47
script/test/imgtest.py
Normal file
47
script/test/imgtest.py
Normal file
@@ -0,0 +1,47 @@
|
||||
###################################################################################################
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
def detect_pucks(ip):
|
||||
aux = grayscale(ip, in_place=False)
|
||||
threshold(aux,0,50)
|
||||
binary_fill_holes(aux)
|
||||
return analyse_particles(aux, 10000,50000,
|
||||
fill_holes = False, exclude_edges = True,print_table=True,
|
||||
output_image = "outlines", minCirc = 0.4, maxCirc = 1.0)
|
||||
|
||||
def detect_samples(ip):
|
||||
aux = grayscale(ip, in_place=False)
|
||||
invert(aux)
|
||||
subtract_background(aux)
|
||||
auto_threshold(aux)
|
||||
binary_open(aux)
|
||||
return analyse_particles(aux, 300,800,
|
||||
fill_holes = False, exclude_edges = True,print_table=True,
|
||||
output_image = "outlines", minCirc = 0.4
|
||||
, maxCirc = 1.0)
|
||||
|
||||
|
||||
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)
|
||||
set_lut(output_puck, outline_lut1[0], outline_lut1[1], outline_lut1[2])
|
||||
set_lut(output_samples, outline_lut2[0], outline_lut2[1], outline_lut2[2])
|
||||
op_image(ip, output_samples, "xor")
|
||||
op_image(ip, output_puck, "xor")
|
||||
return ip.getBufferedImage()
|
||||
|
||||
#Setting the filter to a source
|
||||
img.setFilter(MyFilter())
|
||||
|
||||
15
script/test/ip
Normal file
15
script/test/ip
Normal file
@@ -0,0 +1,15 @@
|
||||
from ijutils import *
|
||||
import java.awt.Color as Color
|
||||
|
||||
ip = load_image(img.getImage())
|
||||
grayscale(ip)
|
||||
#ip=binning(ip,2)
|
||||
gaussian_blur(ip)
|
||||
#bandpass_filter(ip,20, 100)
|
||||
auto_threshold(ip)
|
||||
|
||||
#Particle Analysis
|
||||
(results,output_img)=analyse_particles(ip, 500,2000, print_table=True)
|
||||
output_img.show()
|
||||
|
||||
ip.show()
|
||||
Reference in New Issue
Block a user