Page 1 of 2

Blurring color images with transparency

Posted: 2013-12-17T14:20:47-07:00
by Axolotl
Hi. I have a purpose to make an edge-antialiasing effect on color images.
Here is the example of what i need - http://www.imagemagick.org/Usage/blur/
but it doesn't work this way, if i use channel RGBA it still mixes colors with black, then i've seen explanation that it was a bug and it doesn't work this way anymore. But how now i can get this result? How to make blur with transparency but to keep the colors as they are and not to mix them with black or anything else.

Re: Blurring color images with transparency

Posted: 2013-12-17T17:21:13-07:00
by fmw42
You link does not go to any particular example. Please make the link better or identify which example you are trying. Are you using the example images or your own images. If the latter, then please post a link to your image and your exact command line.

Also always identify your version of IM and platform.

Re: Blurring color images with transparency

Posted: 2013-12-17T17:47:22-07:00
by Axolotl
Using: ImageMagick-6.8.6-Q16 64bit
Windows 7 64bit

First i tried with my images, and when i failed to get what i want, i tried exactly with example pictures and commadlines

Here the link to the chapter http://www.imagemagick.org/Usage/blur/#blur_channel

Here commandline

Code: Select all

convert yellow_circle.png  -channel RGBA  -blur 0x8  yellow_blurred_RGBA.png
Yellow_CircleImage and this what i must get by this example Image

But with this command i get a circle antialiased with black color of transparent pixels
Image

Re: Blurring color images with transparency

Posted: 2013-12-17T18:27:37-07:00
by fmw42
your background is not yellow, but black. So change the background first. This works for me on IM 6.8.7.10 Q16 Mac OSX

convert yellow_circle.png -background yellow -alpha background -channel rgba -blur 0x8 result.png

see
http://www.imagemagick.org/Usage/maskin ... background

Re: Blurring color images with transparency

Posted: 2013-12-18T00:40:44-07:00
by Axolotl
No...no..i don't need yellow circle, it was just a test when i failed to get what i want, then i tried on given in manual example with given pictures and given commandline and still get another result then in manual. The picture in manual also have black background, but have right result, colors isn't mixing with colors of transparent pixels.

Making background with given color is not a solution because i have animated color images (sprites) that have very different colors (for example a man with red hair, blue shirt and yellow pants) and i need to make smooth antialiasing effect on edges, but not to mix with black or whatever, so i can't use such method. I want exactly what is in manual example.

P.S.Here exactly from manual. It's said that using -channel RGBA fixing this problem
https://dl.dropboxusercontent.com/u/847 ... screen.jpg
and here more
https://dl.dropboxusercontent.com/u/847 ... creen2.jpg

more than that later in manual is such message

Before IM version 6.2.4-4, the "-blur", and "-gaussian-blur" operators were applied as pure grey-scale operation, and as such did not adjust color weighting according to their alpha channel 'visibility'. The result was that any form of blurring with transparency, almost always produced horrible 'black halo' effects, such as purposefully generated in the previous example.

This was classed as a major long term bug within the IM distribution, and one that was very hard to workaround. For more details of this problem, see the Blur with Transparency Bug page.


So i think this bug is here again((((

Re: Blurring color images with transparency

Posted: 2013-12-18T01:15:16-07:00
by snibgo
That page hasn't been processed with a recent version of IM, and the examples don't work.

Perhaps the effect wanted by the OP is, for example:

Code: Select all

convert in.png -channel A -blur 0x8 -level 50%%,100% out.png
This blurs just the alpha channel, then levels it so the only visible pixels are those that were opaque.

Re: Blurring color images with transparency

Posted: 2013-12-18T01:30:28-07:00
by Axolotl
snibgo wrote:That page hasn't been processed with a recent version of IM, and the examples don't work.

Perhaps the effect wanted by the OP is, for example:

Code: Select all

convert in.png -channel A -blur 0x8 -level 50%%,100% out.png
This blurs just the alpha channel, then levels it so the only visible pixels are those that were opaque.
No, i need to blur go outside, smoothing out, not just inside. Exactly as in example with yellow circle on black/red/whatever background color but not mixing with transparency color. In example it's just said that -channel RGBA will do this, but it doesn't. So maybe this topic is better to move to Bugs section?

Or maybe there is some other solution? Yes, Photoshop do this as expected, but i don't want to use phtoshop, because i have a lot of images (animated sprites) to convert, so i don't want to use PS scripts for that, i more like commandline tools.

Re: Blurring color images with transparency

Posted: 2013-12-18T01:51:24-07:00
by snibgo
The documentation is out of date.

Please post samples of your input and desired output. You can put them somewhere like dropbox.com and paste the links here. Also please say what version of IM you are using.

Re: Blurring color images with transparency

Posted: 2013-12-18T02:47:32-07:00
by Axolotl
Using: ImageMagick-6.8.6-Q16 64bit
Windows 7 64bit

I alredy post examples of what i need. I need exactly what in manual examples, i need to blur the edge of image out, but not to mix the colors with transparency color (the way it's said in manual). The purpose is to make antialiasing of sprites that need to be using in different backgrunds, so the colors must not be mixed with some specific color. I think it's called Unpremultiplieed Alpha compostioning.

But, ок, here an example of what i tried in Photoshop

Here is in (it has a red background color)
Image
And here is my test out (appliing blur to the image in Photoshop)
Image

See, colors doesn't mixes with red background color, the image just blurring out it's edge colors (if you remove alpha channel you will see it), and this is what said in IM examples, and this is what i need.

Re: Blurring color images with transparency

Posted: 2013-12-18T06:13:12-07:00
by snibgo
The behaviour of "-blur" with transparency changed sometime between v6.8.3-0 and v6.8.4-0, I suspect when it started to use morphology. The documentation has not been updated to reflect this new behaviour. I don't know how to replicate the old behaviour with recent versions.

Re: Blurring color images with transparency

Posted: 2013-12-18T06:28:01-07:00
by Axolotl
Hi again.
Yes, I Tried to do this in version of IM 6.6.5 and it works as expected and as written in manual. So it more like a Bug. Maybe i will better post it in a Bugs section.

Here the demonstration..
This is Unput files with alpha channel and without
Image Image

Here is How it worked in 6.6.5 with using -channel RGBA -blur and in right picture we see what happened in alpha channel if we remove transparency

ImageImage

.............................................................

And here is how it works in new (6.8.6) version of IM :(
Image Image

Re: Blurring color images with transparency

Posted: 2013-12-18T10:51:35-07:00
by fmw42
It is not possible to get the background of the second image simply by blurring the first image! Are you sure you are using the same image on both systems. You need to start with the background of the second image with the alpha channel of the first image.

Re: Blurring color images with transparency

Posted: 2013-12-18T11:49:58-07:00
by Axolotl
fmw42 wrote:It is not possible to get the background of the second image simply by blurring the first image! Are you sure you are using the same image on both systems. You need to start with the background of the second image with the alpha channel of the first image.
Of course the inputs are the same. It's the right way how this must work, and it really worked before, just try older verson of IM (I tried with 6.6.5). It's just some bug crawls in, so i hope it will be fixed soon.

P.S. Just tried 6.8.0 also works as expected.

Re: Blurring color images with transparency

Posted: 2013-12-18T12:19:02-07:00
by fmw42
I do not see how it is possible to get the change you see for the background under the transparency.

Unfortunately, I cannot go back before IM 6.8.6.9 to test. Perhaps one of the other uses might be able to do so and confirm.

Re: Blurring color images with transparency

Posted: 2013-12-18T12:59:22-07:00
by Axolotl
fmw42 wrote:I do not see how it is possible to get the change you see for the background under the transparency.

Unfortunately, I cannot go back before IM 6.8.6.9 to test. Perhaps one of the other uses might be able to do so and confirm.
I can give you a distrib of IM 6.8.0 (if you use windows) if you interestng in this. I'm not quite understand why you don't belive in things that described in manual.

https://dl.dropboxusercontent.com/u/847 ... ws-dll.exe

The command in example was exactly
convert inputfile.png -channel RGBA -blur 0x8 outfile.png