JuliaImages / ImageFiltering.jl

Julia implementations of multidimensional array convolution and nonlinear stencil operations
Other
99 stars 49 forks source link

Type conservation in imfilter #140

Closed mloubout closed 4 years ago

mloubout commented 5 years ago

Hello

It looks like imfilter does not conserve types, for example imfilter(Array{Float32}, kernel) returns Array{Float64}

timholy commented 5 years ago

It can't/shouldn't be fully conservative, otherwise imfilter(::Array{Bool}, kernel) would throw an InexactError for kernels that use floating-point coefficients.

Let me guess, kernel is defined in terms of Float64? What happens if you convert it to Float32, too?

Then the final issue is whether we should do that conversion automagically. I lean away from that because what if filter is something big (say, another image) and you're actually using this to compute a correlation? In such cases img and kernel are on equal footing.

timholy commented 4 years ago

I'm going to close this since there hasn't been any objection to the points raised in my reply.