Bug introduced in 8.0.4 or earlier, persisting through 11.0.1.
There's a number of *Filter
for image processing in Mathematica and they're also supposed to work on array, according to the document. However, they seem not to work properly when Padding -> None
option is added, for example:
lap = LaplacianFilter[#, 1, Padding -> None] &;
When the 1st argument of LaplacianFilter
is an image, Padding -> None
works as expected:
img = Import["ExampleData/rose.gif"];
ImageDimensions@img
(* {223, 164} *)
lap@img // ImageDimensions
(* {221, 162} *)
but when it's just an array, it doesn't:
lap@ConstantArray[1, {3, 3}]
{{-3.21096 + 3.21096 None, -1.52658 + 1.52658 None, -3.21096 + 3.21096 None}, {-1.52658 + 1.52658 None, 0., -1.52658 + 1.52658 None}, {-3.21096 + 3.21096 None, -1.52658 + 1.52658 None, -3.21096 + 3.21096 None}}
The supposed result is {{0.}}
. Apparently LaplacianFilter
has just treated None
as a plain expression.
I haven't done a thorough test, but it seems that all the *Filter
s for image processing have the same issue and *Filter
s for signal processing like BandpassFilter
is not influenced.
Is this a bug? Any workaround?