Skip to content

Commit 6870080

Browse files
committed
Fixes #6: unexpected multiple ROI extraction behavior with single ROI
1 parent d4c981d commit 6870080

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
See DataLab [roadmap page](https://cdlapp.readthedocs.io/en/latest/dev/roadmap.html)
44
for future and past milestones.
55

6+
## DataLab Version 0.9.2 ##
7+
8+
🛠️ Bug fixes:
9+
10+
* Region of interest (ROI) extraction feature for images:
11+
* ROI extraction was not working properly when the "Extract all regions of interest
12+
into a single image object" option was enabled if there was only one defined ROI
13+
* The result was an image positioned at the origin (0, 0) instead of the expected
14+
position (x0, y0) and the ROI rectangle itself was not removed as expected
15+
* [Issue #6](https://github.com/Codra-Ingenierie-Informatique/DataLab/issues/6) - 'Extract multiple ROI' feature: unexpected result for a single ROI
16+
617
## DataLab Version 0.9.1 ##
718

819
🛠️ Bug fixes:

cdl/core/computation/image/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -527,11 +527,18 @@ def extract_multiple_roi(src: ImageObj, group: gds.DataSetGroup) -> ImageObj:
527527
Returns:
528528
ImageObj: output image object
529529
"""
530+
x0 = min(p.x0 for p in group.datasets)
531+
y0 = min(p.y0 for p in group.datasets)
532+
x1 = max(p.x1 for p in group.datasets)
533+
y1 = max(p.y1 for p in group.datasets)
530534
suffix = None
531535
if len(group.datasets) == 1:
532536
p = group.datasets[0]
533537
suffix = p.get_suffix()
534538
dst = dst_11(src, "extract_multiple_roi", suffix)
539+
dst.x0 += x0
540+
dst.y0 += y0
541+
dst.roi = None
535542
if len(group.datasets) == 1:
536543
p = group.datasets[0]
537544
dst.data = src.data.copy()[p.y0 : p.y1, p.x0 : p.x1]
@@ -540,14 +547,7 @@ def extract_multiple_roi(src: ImageObj, group: gds.DataSetGroup) -> ImageObj:
540547
for p in group.datasets:
541548
slice1, slice2 = slice(p.y0, p.y1 + 1), slice(p.x0, p.x1 + 1)
542549
out[slice1, slice2] = src.data[slice1, slice2]
543-
x0 = min(p.x0 for p in group.datasets)
544-
y0 = min(p.y0 for p in group.datasets)
545-
x1 = max(p.x1 for p in group.datasets)
546-
y1 = max(p.y1 for p in group.datasets)
547550
dst.data = out[y0:y1, x0:x1]
548-
dst.x0 += min(p.x0 for p in group.datasets)
549-
dst.y0 += min(p.y0 for p in group.datasets)
550-
dst.roi = None
551551
return dst
552552

553553

0 commit comments

Comments
 (0)