Thinking about it 'screen' is probably the wrong solution as well. 'plus' is probably the right solution to handle masks that share a common edge. See my raw notes...
http://www.imagemagick.org/Usage/masking/#aligning
fmw42 wrote:But I would certainly like to understand why in my example above I had to pipe to a new convert.
I don't know... it worked for me except for some slight aliasing along the edges from the
-transparent color replacement, nothing went wrong with it!
This was the command I used... no pipeline.
Code: Select all
convert bodynormalclassicmod3.png sleevelongnormalmod3.png -fuzz 20% -transparent black -background black -flatten -median 3x3 show:
Thought it was perhaps the use of show: but saving to a PNG produced the same result.
I am using
Code: Select all
convert -version
Version: ImageMagick 6.7.5-10 2012-03-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
So what did your IM do? How did your command go wrong? You don't exactly say, only what you tried.
NOTE: median is purely a channel operator (no sync channel flag handling). As such if you tried it on an image with transparency, it would do nothing as the channel default in IMv6 is RGB and not RGBA. In other words it would not have filled in a line of transparent pixels! This is only relevent if you were trying to use
-background none in your command. Adding -channel RGBA should fix that problem.
Hmmmm.... Under my testing it looks like median destroys alpha (when it is not in -channel setting) rather than preserve it! I have seen this same problem with -sparse-color development with channel restrictions, I know the cause.
Note to Magick for bug fix: When median makes a image clone for its results it is requests a faster 'cleared' image rather than a exact 'copy' of the original image data, thus when it does not apply itself to alpha, alpha does not get copied, and transparency is lost.
ADDITIONAL: median really could be rolled in as a special morphology operator, with the 3x3 being the 'neighbourhood'. As a morphology operator it could use other neighbourhoods than just square (EG: diamonds disks)
ASIDE: I generally avoid using color replacement. I have always considered replacing a range of colors with a single color a bad idea, even though it is a rather common idea. My "bg_removal" script
http://www.imagemagick.org/Usage/scripts/bg_removal
developed from my notes in Recovering Semi-Transparent Edges
http://www.imagemagick.org/Usage/masking/#semi-trans
could now be modified to automatically determine the semi-transparent colors using a 'color diffusion' (well shepards fill) of the internal colors, rather than its current use a fixed 'edge' or 'shadow' color. All you need is a good internal-external contrast and you can recover the edge aliasing near perfectly.
This however is really another topic.