From 2b88cd73c6785c20c001e0ac3dcbf48584bd6231 Mon Sep 17 00:00:00 2001 From: rheintzmann Date: Tue, 13 Jul 2021 16:51:11 +0200 Subject: [PATCH] tiled_processing was slightly changed by removing the res_type argument --- src/TiledViews.jl | 12 ++++++++---- test/runtests.jl | 10 ++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/TiledViews.jl b/src/TiledViews.jl index a2f0607..a466c6b 100644 --- a/src/TiledViews.jl +++ b/src/TiledViews.jl @@ -384,11 +384,11 @@ end """ - tiled_processing(tiled_view::TiledView, fct; res_type = Float32, verbose=true, dtype=Float32, window_function=window_hanning) + tiled_processing(tiled_view::TiledView, fct; verbose=true, dtype=eltype(tiled_view.parent), window_function=window_hanning) processes a raw dataset using tiled views by submitting each tile to the function `fct` and merging the results via the `window_function`. """ -function tiled_processing(tiled_view::TiledView, fct; res_type = Float32, verbose=true, dtype=Float32, window_function=window_hanning) - @time res = zeros_like(tiled_view, res_type) +function tiled_processing(tiled_view::TiledView, fct; verbose=true, dtype=eltype(tiled_view.parent), window_function=window_hanning) + @time res = zeros_like(tiled_view, dtype) res.parent .= zero(dtype) @time win = get_window(tiled_view, window_function=window_function) ttn = get_num_tiles(tiled_view) @@ -404,7 +404,11 @@ function tiled_processing(tiled_view::TiledView, fct; res_type = Float32, verbos return res end -function tiled_processing(data, fct, tile_size, tile_overlap; verbose=true, dtype=nothing, keep_center=false, window_function=window_hanning) +""" + tiled_processing(data, fct; verbose=true, dtype=eltype(data), window_function=window_hanning) + processes a raw dataset using tiled views by submitting each tile to the function `fct` and merging the results via the `window_function`. +""" +function tiled_processing(data, fct, tile_size, tile_overlap; verbose=true, dtype=eltype(data), keep_center=false, window_function=window_hanning) tiles = TiledView(data, tile_size, tile_overlap, keep_center=keep_center); return tiled_processing(tiles,fct; verbose=verbose, dtype=dtype, window_function=window_function) end diff --git a/test/runtests.jl b/test/runtests.jl index ebf8d52..dc31509 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,7 +80,9 @@ end #tiles[:,:,:,:] .+= to_write[:,:,:,:] ; # why can one NOT use [:,:,:,:]? tiles .+= to_write ; # why can one NOT use [:,:,:,:]? @test sum(abs.(dest[50:end-50,50:end-50] .- 1.2)) < 1e-10 - win2, mynorm = get_window(tiles, get_norm=true); + win2, mynorm = get_window(tiles, get_norm=true, verbose=true); + @test all(win .== win2) + tiles, win = TiledWindowView(dest, tile_size, rel_overlap=(1.0,1.0), get_norm=true); @test all(win .== win2) end @@ -93,7 +95,7 @@ end @testset "eachtile" begin q = zeros(100,101); a=TiledView(q, (80,91), (0,0)); - for (t,tn,tc) in zip(eachtile(a),eachtilenumber(a),eachtilerelpos(a)) + for (t,tn,tc,tc2) in zip(eachtile(a),eachtilenumber(a),eachtilerelpos(a),eachtilerelpos(a,2.0)) t[:] .+= tn[1]; end @test q[end,end] == 2 @@ -102,8 +104,8 @@ end @testset "tiled_processing" begin q = ones(10,10,10); a = TiledView(q, (4,4,4), (2,2,2)); - fkt(a)=sin.(a) - res = tiled_processing(a,fkt); + fct(a)=sin.(a) + res = tiled_processing(q, fct, (4,4,4), (2,2,2)) @test maximum(res.parent) ≈ sin(1) end