Skip to content

Commit 7ecbf20

Browse files
authored
Merge pull request #37 from lorenzoh/lo/fix-inplace-project
Fix `project!` for image and mask
2 parents 7877251 + f2ca512 commit 7ecbf20

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DataAugmentation"
22
uuid = "88a5189c-e7ff-4f85-ac6b-e6158070f02e"
33
authors = ["lorenzoh <lorenz.ohly@gmail.com>"]
4-
version = "0.1.5"
4+
version = "0.1.6"
55

66
[deps]
77
ColorBlendModes = "60508b50-96e1-4007-9d6c-f475c410f16b"

src/items/image.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ end
8383
# as they are implicitly given by the buffer.
8484

8585
function project!(bufimage::Image, P, image::Image{N, T}, indices) where {N, T}
86-
# Update index offsets so the correct portion of the image is warped
87-
buf = OffsetArray(itemdata(bufimage), indices)
88-
warp!(
89-
buf,
86+
a = OffsetArray(parent(itemdata(bufimage)), indices)
87+
res = warp!(
88+
a,
9089
box_extrapolation(itemdata(image), zero(T)),
9190
inv(P),
9291
)
93-
return Image(buf, P.(getbounds(image)))
92+
return Image(res, P.(getbounds(image)))
9493
end

src/items/mask.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ end
5151

5252

5353
function project!(bufmask::MaskMulti, P, mask::MaskMulti, indices)
54+
a = OffsetArray(parent(itemdata(bufmask)), indices)
5455
bounds_ = P.(getbounds(mask))
55-
warp!(
56-
itemdata(bufmask),
56+
res = warp!(
57+
a,
5758
mask_extrapolation(itemdata(mask)),
5859
inv(P),
5960
)
60-
return MaskMulti(itemdata(bufmask), mask.classes, P.(getbounds(mask)))
61+
return MaskMulti(a, mask.classes, P.(getbounds(mask)))
6162
end
6263

6364

@@ -115,12 +116,13 @@ end
115116

116117
function project!(bufmask::MaskBinary, P, mask::MaskBinary, indices)
117118
bounds_ = P.(getbounds(mask))
118-
warp!(
119-
itemdata(bufmask),
119+
a = OffsetArray(parent(itemdata(bufmask)), indices)
120+
res = warp!(
121+
a,
120122
mask_extrapolation(itemdata(mask)),
121123
inv(P),
122124
)
123-
return MaskBinary(itemdata(bufmask), P.(getbounds(mask)))
125+
return MaskBinary(res, P.(getbounds(mask)))
124126
end
125127

126128
function showitem!(img, mask::MaskBinary)

0 commit comments

Comments
 (0)