enzoribeirodev / petrou
PublicA modular Python library for image thresholding and segmentation optimization.
Petrou is a Python library that helps you automatically separate objects from backgrounds in grayscale images. It works by finding the optimal brightness cutoff point that divides your image into distinct regions. The library offers three different mathematical approaches (Otsu, Tsallis, and MASI) for finding this cutoff, and uses intelligent search strategies to locate the best threshold even in complex images. You can use it with default settings for quick results, or fine-tune the parameters for specialized images. The library also includes tools to measure how accurate your segmentation is against known correct answers, and can extract intensity profiles along lines in your images.
How It Works
You have a collection of images where you need to separate the important parts from the background, like isolating cells in a microscope image or removing the background from a photo.
You add petrou to your project with a simple command, and it quietly handles all the heavy mathematical lifting behind the scenes.
You bring your image into the program as a simple grid of brightness values, just like opening a photo in any image viewer.
Without you doing any math, the library examines your image's brightness distribution and discovers exactly where to draw the line between foreground and background.
The library estimates the best parameters on its own, giving you a great result with zero extra work.
You provide specific numbers to guide the search, giving you more control over the final result.
If you have a reference image showing the correct answer, the library measures your result against it and tells you the accuracy score.
You now have a clean binary image where the objects you care about are clearly separated from the background, ready for further analysis or use.
Star Growth
Repurpose is a Pro feature
Generate ready-to-use prompts for X threads, LinkedIn posts, blog posts, YouTube scripts, and more -- with full repo context baked in.
Unlock RepurposeSimilar repos coming soon.