Skip to content

Commit c0b6274

Browse files
authored
Merge pull request #15 from CellTrackingChallenge/viz_feature
Viz feature #14
2 parents 0b3acb0 + 0e313c5 commit c0b6274

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ cd py-ctcmetrics
5252
pip install .
5353
```
5454

55+
**Note**: If you want to use the visualization feature, you need to install OpenCV or by installing the optional dependencies:
56+
```bash
57+
pip install py-ctcmetrics[viz]
58+
```
59+
60+
5561
---
5662

5763
## Usage

ctc_metrics/scripts/visualize.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def visualize(
4343
start_frame: int = 0,
4444
framerate: int = 30,
4545
opacity: float = 0.5,
46-
): # pylint: disable=too-many-arguments,too-complex
46+
): # pylint: disable=too-many-arguments,too-complex,too-many-locals
4747
"""
4848
Visualizes the tracking results.
4949
@@ -111,8 +111,12 @@ def visualize(
111111
print(f"\rFrame {img_name} (of {len(images)})", end="")
112112

113113
# Visualize the image
114+
img = tiff.imread(img_path)
115+
p1, p99 = np.percentile(img, (1, 99))
116+
img = np.clip((img - p1) / max(p99 - p1, 1e-5) * 255, 0, 255).astype(np.uint8)
117+
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
114118
viz = create_colored_image(
115-
cv2.imread(img_path),
119+
img,
116120
tiff.imread(res_path),
117121
labels=show_labels,
118122
frame=start_frame,

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
setup(
44
name="py-ctcmetrics",
5-
version="1.1.0",
5+
version="1.2.0",
66
packages=find_packages(),
77
install_requires=[
88
"numpy",
9-
"opencv-python",
109
"scikit-learn",
1110
"scipy",
1211
"tifffile",
1312
"imagecodecs",
1413
"pandas"
1514
],
15+
extras_require={
16+
"viz": ["opencv-python"],
17+
},
1618
author="Timo Kaiser",
1719
author_email="kaiser@tnt.uni-hannover.de",
1820
description="Metrics for Cell Tracking Challenges",

0 commit comments

Comments
 (0)