Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ij import IJ, WindowManager
- from trainableSegmentation import WekaSegmentation
- import Watershed_Irregular_Features
- from ij.process import ImageConverter
- def bubblesizer():
- # Please define the path to your classifier.
- classifer_path = "D:\\Bubbles.model"
- # Gets the image you want to segment.
- your_image = IJ.getFilePath("Select image for WEKA segmentation")
- target = IJ.openImage(your_image)
- #launches weka segmentation.
- weka = WekaSegmentation()
- weka.setTrainingImage(target)
- # Loads the classifier you have trained manually.
- weka.loadClassifier(classifer_path)
- weka.applyClassifier(False)
- # Shows you the segmented image.
- segmentation = weka.getClassifiedImage()
- segmentation.show()
- # Converts to binary, runs watershed segmentation and analyze particles. Outputs area measurements.
- ImageConverter(segmentation).convertToGray8()
- WindowManager.getCurrentImage()
- IJ.run("Make Binary")
- IJ.run("Invert")
- IJ.run(segmentation, "Watershed Irregular Features", "erosion=1 convexity_treshold=0 separator_size=0-200")
- IJ.run("Analyze Particles...", "size=50-Infinity circularity=0.1-1.00 show=Outlines display summarize")
- bubblesizer()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement