Image Segmentation Made Easy: A Guide to Ilastik and EasIlastik for Non-Experts
Author(s): Titouan Le Gourrierec
Originally published on Towards AI.
Introduction
Image segmentation plays a key role in various fields, from identifying cells in biological research to analyzing regions in satellite imagery. However, traditional segmentation methods often require advanced programming skills or machine learning expertise β making them inaccessible to many.
Fortunately, tools like Ilastik and EasIlastik are changing the game. These open-source applications empower users to perform sophisticated image segmentation without writing a single line of code. With intuitive interfaces and interactive workflows, they allow even non-experts to achieve high-quality results quickly.
In this article, weβll explore what makes Ilastik and EasIlastik so powerful, walk through how to use them, and show you how they can simplify your image segmentation tasks, no matter your level of experience.
Ilastik: A powerful tool to segment images
Ilastik is a powerful, open-source tool designed to make complex image analysis tasks like segmentation and object classification accessible to non-experts. With no prior experience in machine learning required, it empowers users to create customized models by simply annotating images, making it perfect for anyone who needs to process visual data.
It uses interactive machine learning, allowing users to annotate images directly, train models in real-time, and apply them without needing programming skills. From biological microscopy to industrial inspection, Ilastik is versatile and ideal for a wide range of applications.
To download Ilastik, please visit Ilastik website and follow the installation instructions for your operating system.
How to use it?
Once youβve downloaded Ilastik, launch the software and select βPixel Classificationβ under the βSegmentation Workflowsβ section to get started.
1. Loading Images for Model Training
To begin, add the images needed for training the model:
- Click on the βAdd Newβ button.
- Select βAdd separate imagesβ to upload your image files.
2. Feature Selection
Next, click on the β2. Feature Selectionβ button in the left-hand menu. A popup will appear with a set of feature checkboxes.
- Select all the boxes. These features represent different image properties like edges, textures, and intensity patterns. Donβt worry β Ilastik will automatically determine which ones are most relevant based on the images you provide.
- Click βOKβ, then proceed to β3. Trainingβ.
3. Annotating Images
Now comes the interactive part:
- Add the labels you need for each class in your dataset.
- Use the pen tool to annotate regions on your images, assigning them to the appropriate labels.
4. Refining the Model with Incremental Learning
Once youβve made your initial annotations, click on the βSuggest Featuresβ button. This allows Ilastik to select the most relevant features for your specific dataset.
Hereβs where Ilastik shines: you can incrementally improve the modelβs predictions.
- Review the segmentation results produced by your model.
- Annotate more areas or correct any inaccuracies to refine the predictions further.
This iterative approach ensures that your model adapts to the complexity of your data.
5. Exporting Predictions and Saving the Model
Once youβre satisfied with the results:
- Click on β4. Prediction Exportβ in the left menu.
- Open βChoose Export Image Settingsβ and adjust the βRenormalize [min, max]β parameter to reflect the number of classes in your dataset (e.g., 0 to the number of labels you created).
- Save the model as an .ilp file for future use.
Using Your Trained Model with Python and EasIlastik
Once youβve trained and saved your Ilastik model as a .ilp file, you can seamlessly integrate it into your Python workflow using the EasIlastik package. EasIlastik simplifies running your Ilastik model on large datasets without needing to open the Ilastik interface, making it ideal for batch processing and automation.
1. Installing EasIlastik
Before using EasIlastik, youβll need to install it. You can do this easily via pip:
pip install EasIlastik
2. Running Your Model with EasIlastik
Once youβve installed the package, you can use it to apply your trained Ilastik model to new images. The process is simple and involves just a few lines of code:
import EasIlastik
EasIlastik.run_ilastik(
input_path="path/to/input/folder",
model_path="path/to/your/model.ilp",
result_base_path="path/to/your/output/folder/"
)
Explanation of Parameters:
input_path
: This is the path to the image or folder containing the images you want to process. EasIlastik can handle a single image or multiple images in a folder.model_path
: This is the path to your saved Ilastik model file (.ilp). Itβs the model you trained using the Ilastik interface, and now youβre ready to apply it to new data.result_base_path
: Specify the path where you want the processed results to be saved. EasIlastik will store the output files here.
Why Use EasIlastik?
- Batch Processing: Easily process hundreds or thousands of images at once. This is especially useful for large datasets where manually running predictions in Ilastikβs GUI would be too time-consuming.
- Automation: Integrating EasIlastik into your Python scripts allows you to automate your image segmentation pipeline, enabling seamless workflows for repeated tasks.
- Simplicity: Despite its power, EasIlastik is simple to use, requiring minimal code. This makes it accessible even to those with little to no programming experience.
- Flexibility: EasIlastik provides the flexibility to incorporate Ilastikβs powerful segmentation capabilities into larger data processing pipelines, whether for research, industrial applications, or other fields.
With just a few lines of code, you can easily process large batches of images using the model you trained in Ilastik, making EasIlastik a powerful tool for automating and scaling image segmentation tasks.
Conclusion
Ilastik and EasIlastik offer a powerful, accessible solution for image segmentation, ideal for users with no prior AI knowledge. Their intuitive interfaces and interactive workflows allow users to easily tackle complex segmentation tasks. By eliminating the need for specialized coding or deep machine learning knowledge, these tools accelerate research, reduce human error, and enable efficient, high-quality image analysis.
Whether for biological research, industrial applications, or other fields, Ilastik makes image segmentation easy. EasIlastik further simplifies the process by allowing seamless integration with Python for batch processing.
Give Ilastik a try and unlock the full potential of your image data!
Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.
Published via Towards AI