ImageFiltering.jl icon indicating copy to clipboard operation
ImageFiltering.jl copied to clipboard

Output image incorrect when OffsetArray vectors passed as kernel components

Open BioTurboNick opened this issue 7 months ago • 4 comments

If a 2d kernel is passed as two OffsetArray vectors, the second one transposed or adjoint, the final image is incorrect.

The issue does not occur if the second component is an OffsetArray matrix with one row, or if the vector is transposed /adjointed before being passed to centered.

image = [0.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 0.0]
image_out_typical = imfilter(image, Kernel.gaussian(1))

factor1, factor2 = ImageFiltering.factorkernel(Kernel.gaussian(1))
@info factor1
@info factor2
	
image_out_factors = imfilter(image, (factor1, factor2))

factor1a = factor1 |> vec |> centered
factor2a = (factor2 |> vec |> centered)'

@info factor1a
@info factor2a

image_out_factors_vec = imfilter(image, (factor1a, factor2a))
	
plot(heatmap(image, aspectratio = 1), heatmap(image_out_typical, aspectratio = 1), heatmap(image_out_factors, aspectratio = 1), heatmap(image_out_factors_vec, aspectratio = 1))

image image

BioTurboNick avatar Nov 30 '23 21:11 BioTurboNick