Skip to content

Commit d017402

Browse files
Some doc updates and cosmetics
1 parent b679e2d commit d017402

4 files changed

Lines changed: 45 additions & 76 deletions

File tree

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Install package and docs tooling
2727
run: python -m pip install -v ".[test]" pdoc
2828
- name: Build docs
29-
run: pdoc bioimage_cpp -o docs
29+
run: PYTHONPATH=src pdoc bioimage_cpp -o docs
3030
- uses: actions/upload-pages-artifact@v3
3131
with:
3232
path: docs

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ Don't add `std::chrono` snippets ad hoc; use the existing macros so future profi
192192
193193
## Documentation
194194
195-
`README.md` covers: what `bioimage-cpp` is and isn't, install/build, minimal examples, design philosophy. Public functions need concise docstrings documenting input shapes, supported dtypes, output shapes/dtypes, copy behavior, background-label behavior (if relevant), and axis/coordinate conventions.
196-
197195
Update `MIGRATION_GUIDE.md` whenever public functionality changes, so users migrating from `nifty`/`affogato` see the corresponding `bioimage-cpp` API, behavioral differences, and intentional improvements.
198196
197+
The documentation is build via pdoc, see `.github/workflow/docs.yaml`.
198+
199199
## Checklist when modifying code
200200
201201
1. Reuse existing `detail/` helpers; add new shared ones rather than duplicating.

README.md

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,5 @@
11
# bioimage-cpp
22

3-
Stand-alone implementation of image analysis and segmentaton functionality in C++ with minimal python bindings.
3+
Image processing and segmentation functionality in C++ with light-weight python bindings through nanobind and minimal dependencies to enable distribution via pip.
44

5-
`bioimage-cpp` is a small C++/Python package for dependency-light bioimage-analysis algorithms that are difficult to install from larger C++ libraries. It exposes NumPy-based Python APIs backed by a focused C++20 core.
6-
7-
## Install
8-
9-
```bash
10-
python -m pip install bioimage-cpp
11-
```
12-
13-
## Build from source
14-
15-
```bash
16-
python -m pip install -v ".[test]"
17-
pytest -q
18-
```
19-
20-
## Example
21-
22-
```python
23-
import numpy as np
24-
import bioimage_cpp as bic
25-
26-
labels = np.array([1, 3, 2, 1], dtype=np.uint64)
27-
relabeling = {1: 10, 2: 20, 3: 30}
28-
29-
out = bic.utils.take_dict(relabeling, labels)
30-
# array([10, 30, 20, 10], dtype=uint64)
31-
```
32-
33-
```python
34-
affinities = np.ones((2, 4, 4), dtype=np.float32)
35-
offsets = [[0, 1], [1, 0]]
36-
37-
segmentation = bic.segmentation.mutex_watershed(
38-
affinities,
39-
offsets,
40-
number_of_attractive_channels=2,
41-
)
42-
```
43-
44-
```python
45-
image = np.arange(64, dtype=np.float32).reshape(8, 8)
46-
matrix = np.array([[1.0, 0.0, 0.5], [0.0, 1.0, -1.0]])
47-
48-
transformed = bic.transformation.affine_transform(
49-
image,
50-
matrix,
51-
order=3,
52-
fill_value=0,
53-
)
54-
```
55-
56-
```python
57-
graph = bic.graph.UndirectedGraph.from_edges(4, [[0, 1], [1, 2], [2, 3]])
58-
graph.find_edge(2, 1)
59-
# 1
60-
61-
grid = bic.graph.grid_graph((64, 64))
62-
grid.number_of_edges
63-
# 8064
64-
65-
edge_weights = bic.graph.grid_boundary_features(grid, boundary_map)
66-
local_weights, valid_edges, lifted_uvs, lifted_weights, offset_ids = (
67-
bic.graph.grid_affinity_features_with_lifted(grid, affinities, offsets)
68-
)
69-
```
70-
71-
## Scope
72-
73-
The project is not a compatibility layer for `nifty`, `vigra`, or other large libraries. It keeps I/O and heavy dependencies out of the C++ core; callers should use existing Python packages for file formats and pass NumPy arrays into `bioimage-cpp`.
5+
Please refer to [the documentation](https://computational-cell-analytics.github.io/bioimage-cpp/) for details.

src/bioimage_cpp/__init__.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
"""`bioimage_cpp` implements functionality needed for image procesing in C++.
1+
"""`bioimage_cpp` implements image processing and segmentation functionality in C++.
22
It generates light-weight python bindings with nanobind with minimal dependencies to enable distribution via pip.
33
4-
The main goal of this library is to provide functionality that is missing from scipy or scikit-image or
5-
to provide more performant versions of functionality from these libraries.
4+
The main goal of this library is to provide functionality that is missing from scipy or scikit-image,
5+
or to provide more performant versions of functionality from these libraries.
66
77
The functionality implemented here bundles and improves algorithms etc. from:
88
- [affogato](https://github.com/constantinpape/affogato)
@@ -19,6 +19,43 @@
1919
2020
TODO: document once on pip / conda
2121
22+
## Functionality
23+
24+
This library provides the following functionality:
25+
- `affinities`: functionality for deriving affinities from segmentations.
26+
- `filters`: efficient implementation of convolutional image filters.
27+
- `graph`: graph creation and graph (partitioning) algorithms.
28+
- `segmentation`: image segmentation functionality.
29+
- `transformation`: affine transformations.
30+
- `util`: misc utility functionality.
31+
32+
## Example
33+
34+
Below is a simple example for creating and partitioning a graph with this library.
35+
For more realistic use-cases check out [the migration guide](migration-guide).
36+
37+
```python
38+
import numpy as np
39+
import bioimage_cpp as bic
40+
41+
# Create a graph with 50 nodes.
42+
graph = bic.graph.undirected_graph(number_of_nodes=50)
43+
44+
# Insert a bunch of edges forming a chain.
45+
graph.insert_edges(
46+
np.concatenate([np.arange(0, 49)[:, None], np.arange(1, 50)[:, None]], axis=1)
47+
)
48+
49+
# Create edge weights in [-1, 1].
50+
weights = 2 * np.random.rand(graph.number_of_edges) - 1
51+
52+
# Partition the graph via multicut (greedy solver).
53+
objective = bic.graph.MulticutObjective(graph, weights)
54+
solver = bic.graph.GreedyAdditiveMulticut()
55+
partition = solver.optimize(objective)
56+
print("Partitioned into", len(np.unique(partition)), "elements")
57+
```
58+
2259
.. include:: ../../MIGRATION_GUIDE.md
2360
"""
2461

0 commit comments

Comments
 (0)