What is the logic of transparency handling by image-processing functions?

GROUPS:
 Alexey Popkov 5 Votes When working on this post I discovered that starting from Mathematica 10.0 the behavior of such functions as Blur, GaussianFilter, ImageConvolve and some others was changed. Namely, they no longer affect alpha channel of an Image they are applied to. Unfortunately the Documentation is completely silent about this important change which has broken all dependent code, including this ingenious function written by Heike. My interpretation was that the purpose of this incompatible change is to make transparency handling by all image processing functions be consistent. In versions 8 and 9 ImageAdjust, Dilation and some other similar functions weren't applied to alpha channel. The consistent implementation is to make them all to ignore alpha channel or make them all to process alpha channel (or, better, make this behavior optional). But further investigation showed that even in the latest version 11.2.0 there are strongly related functions which still affect alpha channel: ImageCorrelate and ImageFilter (and may be others, I didn't test every function). Is it a bug that ImageCorrelate and ImageFilter still affect alpha channel? If so, we should expect another code-breaking change in one of the future releases of Mathematica. Or is it by design and we can rely on this functionality? If so, what is the logic behind this design decision? Currently I see no way to predict this behavior, and there is also no information in the Docs. Is there any method to know besides testing every function by hand?(Cross-posted on Mathematica.SE.)
Answer
6 months ago
2 Replies
 Vitaliy Kaurov 2 Votes At the moment I can just tell you that the issue is known and internal teams are looking into this. Please stay tuned for resolution. Thanks for bringing this up and taking the time to describe it.
Answer
5 months ago
 I can add that some basic functions seem to be simply confused by alpha channel. For example, ImageCrop can't crop: img = Rasterize[ Graphics[Rectangle[], PlotRange -> {{-2, 2}, {-2, 2}}, ImageSize -> 200], Background -> None]; ImageCrop[img] // Framed  One workaround is to temporarily set ColorSpace -> Automatic: Image[ImageCrop[Image[img, ColorSpace -> Automatic]], ColorSpace -> "RGB"]  Dedicated thread: https://mathematica.stackexchange.com/q/20494/280Reported to the support as [CASE:3968587].
Answer
4 months ago