wellcrop 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,218 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
wellcrop-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Arseni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,106 @@
1
+ Metadata-Version: 2.5
2
+ Name: wellcrop
3
+ Version: 0.1.0
4
+ Summary: A computer vision utility for automated detection, alignment, and extraction of wells from multi-well plate scans.
5
+ Author: Districtfine
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
17
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
18
+ Requires-Python: >=3.9
19
+ Requires-Dist: numpy>=1.22.0
20
+ Requires-Dist: opencv-python>=4.5.0
21
+ Requires-Dist: scipy>=1.9.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: matplotlib>=3.5.0; extra == 'dev'
24
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
25
+ Requires-Dist: tifffile>=2023.1.0; extra == 'dev'
26
+ Provides-Extra: viz
27
+ Requires-Dist: matplotlib>=3.5.0; extra == 'viz'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # wellcrop
31
+
32
+ A lightweight computer vision utility for automated detection, alignment, and extraction of individual wells from multi-well plate scans.
33
+
34
+ ---
35
+
36
+ ## Highlights
37
+
38
+ * 🔍 **Shift & Skew Tolerant:** Accommodates hand-placed plates on flatbed scanners via directional gradient edge snapping and 2D affine grid estimation.
39
+ * 🎯 **Hough Ring Locking:** Snaps analytic well centers to physical plastic rims via localized Hough circle transforms.
40
+ * ✂️ **Automatic Masking:** Crops and isolates pure circular wells, shaving off outer plastic rims and blacking out corners.
41
+ * 🪶 **Zero Heavy AI Dependencies:** No PyTorch, CUDA, or model weights required. Built purely on `numpy`, `opencv-python`, and `scipy`.
42
+
43
+ ---
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ pip install wellcrop
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Quickstart
54
+
55
+ ```python
56
+ import tifffile as tifi
57
+ import wellcrop
58
+
59
+ # 1. Load scan image
60
+ image = tifi.imread("plate_scan.tif")
61
+
62
+ # 2. Define ROI hints (fractions in [0, 1] drawn once on a reference scan)
63
+ roi_hints = [
64
+ {"x": 0.05, "y": 0.08, "w": 0.40, "h": 0.84, "rows": 3, "cols": 2, "letter": "A"}
65
+ ]
66
+
67
+ # 3. Detect & extract well crops
68
+ detector = wellcrop.PlateDetector(margin_frac=0.20)
69
+ wells = detector.crop(image, roi_hints=roi_hints)
70
+
71
+ # 4. Access individual well crops and metadata
72
+ for well in wells:
73
+ print(f"Well {well.label}: center=({well.x}, {well.y}), radius={well.radius}px")
74
+ # well.image is a circular-masked NumPy RGB array
75
+ well.save(f"output/{well.label}.png")
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Visual QA Overlay
81
+
82
+ Generate diagnostic overlays (showing padded search boxes, detected plate boxes, and snapped well rings):
83
+
84
+ ```python
85
+ import cv2
86
+
87
+ # Draw overlay directly onto the scan
88
+ overlay = wellcrop.draw_overlay(image, wells, roi_hints=roi_hints)
89
+ cv2.imwrite("grid_preview.png", cv2.cvtColor(overlay, cv2.COLOR_RGB2BGR))
90
+ ```
91
+
92
+ ---
93
+
94
+ ## How it Works
95
+
96
+ 1. **ROI-Scoped Search:** Expands the user's initial approximate plate bounding box by `margin_frac` to absorb scanner placement shift.
97
+ 2. **Directional Edge Snapping:** Projects Sobel gradients along vertical and horizontal axes to find true plate walls, reconciling them under rigid geometry constraints.
98
+ 3. **Stacked Plate Reconciliation:** Identifies shared dividing ribs for multi-tray formats so vertically stacked plates never overlap.
99
+ 4. **Grid Estimation & Ring Snapping:** Computes analytic well centers, locks physical rims with local Hough circle searches, and fits a 2D affine transform to absorb plate rotation.
100
+ 5. **Rim Trimming & Masking:** Shaves outer plastic rims and masks corners so downstream analyzers only see pure well contents.
101
+
102
+ ---
103
+
104
+ ## License
105
+
106
+ MIT License. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,77 @@
1
+ # wellcrop
2
+
3
+ A lightweight computer vision utility for automated detection, alignment, and extraction of individual wells from multi-well plate scans.
4
+
5
+ ---
6
+
7
+ ## Highlights
8
+
9
+ * 🔍 **Shift & Skew Tolerant:** Accommodates hand-placed plates on flatbed scanners via directional gradient edge snapping and 2D affine grid estimation.
10
+ * 🎯 **Hough Ring Locking:** Snaps analytic well centers to physical plastic rims via localized Hough circle transforms.
11
+ * ✂️ **Automatic Masking:** Crops and isolates pure circular wells, shaving off outer plastic rims and blacking out corners.
12
+ * 🪶 **Zero Heavy AI Dependencies:** No PyTorch, CUDA, or model weights required. Built purely on `numpy`, `opencv-python`, and `scipy`.
13
+
14
+ ---
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install wellcrop
20
+ ```
21
+
22
+ ---
23
+
24
+ ## Quickstart
25
+
26
+ ```python
27
+ import tifffile as tifi
28
+ import wellcrop
29
+
30
+ # 1. Load scan image
31
+ image = tifi.imread("plate_scan.tif")
32
+
33
+ # 2. Define ROI hints (fractions in [0, 1] drawn once on a reference scan)
34
+ roi_hints = [
35
+ {"x": 0.05, "y": 0.08, "w": 0.40, "h": 0.84, "rows": 3, "cols": 2, "letter": "A"}
36
+ ]
37
+
38
+ # 3. Detect & extract well crops
39
+ detector = wellcrop.PlateDetector(margin_frac=0.20)
40
+ wells = detector.crop(image, roi_hints=roi_hints)
41
+
42
+ # 4. Access individual well crops and metadata
43
+ for well in wells:
44
+ print(f"Well {well.label}: center=({well.x}, {well.y}), radius={well.radius}px")
45
+ # well.image is a circular-masked NumPy RGB array
46
+ well.save(f"output/{well.label}.png")
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Visual QA Overlay
52
+
53
+ Generate diagnostic overlays (showing padded search boxes, detected plate boxes, and snapped well rings):
54
+
55
+ ```python
56
+ import cv2
57
+
58
+ # Draw overlay directly onto the scan
59
+ overlay = wellcrop.draw_overlay(image, wells, roi_hints=roi_hints)
60
+ cv2.imwrite("grid_preview.png", cv2.cvtColor(overlay, cv2.COLOR_RGB2BGR))
61
+ ```
62
+
63
+ ---
64
+
65
+ ## How it Works
66
+
67
+ 1. **ROI-Scoped Search:** Expands the user's initial approximate plate bounding box by `margin_frac` to absorb scanner placement shift.
68
+ 2. **Directional Edge Snapping:** Projects Sobel gradients along vertical and horizontal axes to find true plate walls, reconciling them under rigid geometry constraints.
69
+ 3. **Stacked Plate Reconciliation:** Identifies shared dividing ribs for multi-tray formats so vertically stacked plates never overlap.
70
+ 4. **Grid Estimation & Ring Snapping:** Computes analytic well centers, locks physical rims with local Hough circle searches, and fits a 2D affine transform to absorb plate rotation.
71
+ 5. **Rim Trimming & Masking:** Shaves outer plastic rims and masks corners so downstream analyzers only see pure well contents.
72
+
73
+ ---
74
+
75
+ ## License
76
+
77
+ MIT License. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "wellcrop"
7
+ version = "0.1.0"
8
+ description = "A computer vision utility for automated detection, alignment, and extraction of wells from multi-well plate scans."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ { name = "Districtfine" }
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Science/Research",
18
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
19
+ "Topic :: Scientific/Engineering :: Image Processing",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ ]
27
+ dependencies = [
28
+ "numpy>=1.22.0",
29
+ "opencv-python>=4.5.0",
30
+ "scipy>=1.9.0",
31
+ ]
32
+
33
+ [project.optional-dependencies]
34
+ dev = [
35
+ "pytest>=7.0.0",
36
+ "tifffile>=2023.1.0",
37
+ "matplotlib>=3.5.0",
38
+ ]
39
+ viz = [
40
+ "matplotlib>=3.5.0",
41
+ ]
42
+
43
+ [tool.hatch.build.targets.wheel]
44
+ packages = ["src/wellcrop"]
@@ -0,0 +1,35 @@
1
+ """wellcrop: A computer vision utility for automated detection, alignment, and extraction of wells from multi-well plate scans."""
2
+
3
+ from .detector import PlateDetector, detect_wells_from_rois
4
+ from .edges import (
5
+ detect_plate_rect_edges,
6
+ reconcile_vertical_borders,
7
+ resolve_axis,
8
+ snap_edge,
9
+ )
10
+ from .geometry import pad_box, roi_frac_to_px, well_grid_fracs
11
+ from .grid import fit_grid_axis, fit_grid_transform, place_wells
12
+ from .refine import refine_well
13
+ from .visualization import draw_overlay, render_overlay_matplotlib
14
+ from .well import Well
15
+
16
+ __version__ = "0.1.0"
17
+
18
+ __all__ = [
19
+ "PlateDetector",
20
+ "Well",
21
+ "detect_wells_from_rois",
22
+ "draw_overlay",
23
+ "render_overlay_matplotlib",
24
+ "refine_well",
25
+ "place_wells",
26
+ "fit_grid_axis",
27
+ "fit_grid_transform",
28
+ "detect_plate_rect_edges",
29
+ "snap_edge",
30
+ "resolve_axis",
31
+ "reconcile_vertical_borders",
32
+ "roi_frac_to_px",
33
+ "pad_box",
34
+ "well_grid_fracs",
35
+ ]