@@ -139,34 +139,60 @@ include("../imports.jl")
139
139
@test_nowarn apply! (buffer, tfm, image2)
140
140
end
141
141
142
- @testset ExtendedTestSet " FlipX 2D: flip dimension of 1 = identity" begin
143
- tfm = FlipX {2} ()
144
- img = rand (RGB, 10 , 1 )
142
+
143
+ @testset ExtendedTestSet " FlipX 2D correct indices" begin
144
+ tfm = FlipX {2} () |> RandomCrop ((10 ,10 )) |> PinOrigin ()
145
+ img = rand (RGB, 10 , 10 )
145
146
item = Image (img)
146
147
@test_nowarn titem = apply (tfm, item)
147
148
titem = apply (tfm, item)
148
- @test itemdata (titem) == img
149
+ @test itemdata (titem) == img[:, end : - 1 : 1 ]
149
150
end
150
151
151
- @testset ExtendedTestSet " FlipZ 3D: flip dimension of 1 = identity " begin
152
- tfm = FlipZ {3} ()
153
- img = rand (RGB, 10 , 10 , 1 )
152
+ @testset ExtendedTestSet " FlipY 2D correct indices " begin
153
+ tfm = FlipY {2} () |> RandomCrop (( 10 , 10 )) |> PinOrigin ()
154
+ img = rand (RGB, 10 , 10 )
154
155
item = Image (img)
155
156
@test_nowarn titem = apply (tfm, item)
156
157
titem = apply (tfm, item)
157
- @test itemdata (titem) == img
158
+ @test itemdata (titem) == img[ end : - 1 : 1 , :]
158
159
end
159
160
160
- @testset ExtendedTestSet " `RandomCrop` correct indices" begin
161
- # Flipping followed by cropping should be the same as reverse-indexing
162
- # the flipped dimension
163
- tfm = FlipX {2} () |> RandomCrop ((64 , 64 )) |> PinOrigin ()
164
- img = rand (RGB, 64 , 64 )
161
+
162
+ @testset ExtendedTestSet " FlipX 3D correct indices" begin
163
+ tfm = FlipX {3} () |> RandomCrop ((10 ,10 ,10 )) |> PinOrigin ()
164
+ img = rand (RGB, 10 , 10 , 10 )
165
165
item = Image (img)
166
+ @test_nowarn titem = apply (tfm, item)
166
167
titem = apply (tfm, item)
167
- timg = itemdata (titem)
168
- rimg = img[:, end : - 1 : 1 ]
169
- @test titem. data == rimg
168
+ @test itemdata (titem) == img[end : - 1 : 1 , :, :]
169
+ end
170
+
171
+ @testset ExtendedTestSet " FlipY 3D correct indices" begin
172
+ tfm = FlipY {3} () |> RandomCrop ((10 ,10 ,10 )) |> PinOrigin ()
173
+ img = rand (RGB, 10 , 10 , 10 )
174
+ item = Image (img)
175
+ @test_nowarn titem = apply (tfm, item)
176
+ titem = apply (tfm, item)
177
+ @test itemdata (titem) == img[:, end : - 1 : 1 , :]
178
+ end
179
+
180
+ @testset ExtendedTestSet " FlipZ 3D correct indices" begin
181
+ tfm = FlipZ {3} () |> RandomCrop ((10 ,10 ,10 )) |> PinOrigin ()
182
+ img = rand (RGB, 10 , 10 , 10 )
183
+ item = Image (img)
184
+ @test_nowarn titem = apply (tfm, item)
185
+ titem = apply (tfm, item)
186
+ @test itemdata (titem) == img[:, :, end : - 1 : 1 ]
187
+ end
188
+
189
+ @testset ExtendedTestSet " Double flip is identity" begin
190
+ tfm = FlipZ {3} () |> FlipZ {3} () |> RandomCrop ((10 ,10 ,10 )) |> PinOrigin ()
191
+ img = rand (RGB, 10 , 10 , 10 )
192
+ item = Image (img)
193
+ @test_nowarn titem = apply (tfm, item)
194
+ titem = apply (tfm, item)
195
+ @test itemdata (titem) == img
170
196
end
171
197
end
172
198
0 commit comments