promote fillvalue type if it is Colorant#25
Conversation
It's weird that regions are not filled by `fillvalue` in following cases
PaddedView(colorant"red", fill(Gray(0.), 2, 2), (-1:4, -1:4))
This commit introduce a new non-exported trait `filltype` to promote
fillvalue type so that these kinds of behaviors are corrected.
Missing and Nothing are also handled by `filltype`
|
I now think this patch should go to ImageCore instead of this package. |
This ensure that `fillvalue` is of dominant role of eltype of PaddedView. One consequence of this is transparent color is correctly filled even if `img` isn't of eltype `ARGB`: `PaddedView(ARGB(0, 0, 0, 0), img, indices)` This is a rework of JuliaArrays/PaddedViews.jl#25 and co-operates JuliaArrays/PaddedViews.jl#26
|
closed in favor of #26 |
|
Sorry to be slow to look at this, "real work" has been quite insane lately. Next week should settle out considerably. What about adding a constructor |
Keep safe! ❤️
Exporting the type control to users looks good to me, but I'm a little worried when this usage being abused, e.g., julia> A = rand(Float64, 512, 512);
julia> @btime collect(PaddedView(0, $A, (-2:515, -2:515)));
167.392 μs (3 allocations: 2.05 MiB)
julia> @btime collect(PaddedView{Float32}(0, $A, (-2:515, -2:515)));
195.014 μs (3 allocations: 1.02 MiB)would this be an issue? |
|
In the first case values are being returned directly from julia> using BenchmarkTools, MappedArrays
julia> A = rand(Float64, 512, 512);
julia> B64 = of_eltype(Float64, A);
julia> B32 = of_eltype(Float32, A);
julia> @btime collect($B64);
106.468 μs (2 allocations: 2.00 MiB)
julia> @btime collect($B32);
71.884 μs (2 allocations: 1.00 MiB)but the presence of a branch here is not to be discounted. |
|
I think I benchmarked incorrectly, the memory reallocation differs for Float32 and Float64. The new benchmark is left in #27 |
It's weird that regions are not filled by
fillvaluein following casesCases such as transparent colors as
fillvalueare also handled.The only issue I see is the loading time:
If the loading time is unacceptable, the only place I can think of is
ImageShow/ImageCore-- but that would be type piracy IIUC.This PR serves JuliaImages/ImageShow.jl#19 to make
mosaicviewa really usefulimshowalternative