@@ -139,34 +139,60 @@ include("../imports.jl")
139139 @test_nowarn apply! (buffer, tfm, image2)
140140 end
141141
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 )
145146 item = Image (img)
146147 @test_nowarn titem = apply (tfm, item)
147148 titem = apply (tfm, item)
148- @test itemdata (titem) == img
149+ @test itemdata (titem) == img[:, end : - 1 : 1 ]
149150 end
150151
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 )
154155 item = Image (img)
155156 @test_nowarn titem = apply (tfm, item)
156157 titem = apply (tfm, item)
157- @test itemdata (titem) == img
158+ @test itemdata (titem) == img[ end : - 1 : 1 , :]
158159 end
159160
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 )
165165 item = Image (img)
166+ @test_nowarn titem = apply (tfm, item)
166167 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
170196 end
171197end
172198
0 commit comments