Blur, GaussianFilter and ImageConvolve doesn't work on some images

Starting from Mathematica 10.0 such functions as Blur, GaussianFilter, ImageConvolve etc. don't affect alpha channel of an Image anymore. This change makes their behavior consistent with such related functions as ImageAdjust, Dilation, ImageEffect etc. which didn't change the alpha channel in previous versions. Hence it looks more like a bug fix.

To reproduce the old behavior, we should remove the ColorSpace information which is used to determine which color channel is the alpha channel. According to the Documentation page for ImageColorSpace, Automatic colorspace means that "no color space specified". Let us try:

Image[Blur[Image[img, ColorSpace -> Automatic], 5], ColorSpace -> ImageColorSpace[img]]

ColorSeparate[%]

image

output

Equivalently one can apply Blur separately to each channel:

ColorCombine[Blur[#, 5] & /@ ColorSeparate[img], ImageColorSpace[img]]

image


Another way is to use a function which is still applied to the alpha channel.

As of Mathematica 11.2.0, ImageFilter works with all the channels:

ImageFilter[Mean[Flatten[#]] &, img, 3]
ColorSeparate[%]

image

output

A bit surprisingly, but ImageCorrelate is also still applied to the alpha channel (Mathematica 11.2.0):

ImageCorrelate[img, GaussianMatrix[5]]
ColorSeparate[%]

image

output

I don't know why the exception is made for these two functions. May be a bug?


This is happening because the Imagedata in your image is all zeros

img = Import["http://i.stack.imgur.com/UsJTa.png"]

When you filter (or Blur or ImageConvolve) an image of all zeros, you get back an image with all zeros. The reason you see anything at all is because the alpha channel is sometimes zero and sometimes one. You can verify this by removing the alpha channel:

RemoveAlphaChannel[img]

enter image description here

So the bottom line is that Blur (and the other functions, presumably) only work on the image data, and not on the alpha channel.

To make Blur will work on this image, you can place the alpha channel into a data channel. Here's one way:

img2 = Image[ImageData[img] /. {r_, g_, b_, alpha_} -> 1 - alpha];
Blur[img2, 5]

enter image description here