Page 1 of 1

Anti-aliased stroked mask using distance transform

Posted: 2012-08-09T20:08:35-07:00
by thevinn
From a binary mask it is possible to generate an anti-aliased stroke using an exact distance transform:

Image

Re: Anti-aliased stroked mask using distance transform

Posted: 2012-09-02T22:53:50-07:00
by anthony
Strokes in IM are anti-aliased. At least in my experience.

Distance transform however requires the anti-alising pixels converted to 'distance' (below 'unit' distance, default=100 per pixel width) before the main distance function runs.

For details see... Distance with an Anti-Aliased Shape
http://www.imagemagick.org/Usage/morpho ... anti-alias

And no there is no internal function for this as yet. PS: anti-aliasing pixels may have been generated in a linear colorspace, or a gamma/sRGB colorspace, which many need to be corrected. This was not looked at when I wrote that set of examples.

Re: Anti-aliased stroked mask using distance transform

Posted: 2013-01-06T19:50:07-07:00
by thevinn
anthony wrote:Distance transform however requires the anti-alising pixels converted to 'distance' (below 'unit' distance, default=100 per pixel width) before the main distance function runs.
With the new information regarding Outer Glow and what not, to reproduce Photoshop's "Stroke" effect, it suffices merely to perform the same morphological dilation as in Drop Shadow, and skip the Blur step (i.e. spread == 100%).
And no there is no internal function for this as yet. PS: anti-aliasing pixels may have been generated in a linear colorspace
Photoshop uses linear color space for RGB when performing internal calculations (like anti-aliasing).

Re: Anti-aliased stroked mask using distance transform

Posted: 2013-01-06T22:03:33-07:00
by anthony
I am not disagreeing with you. But you need to convert some of the distance measurements into semi-transparent anti-aliasing pixels.

I have converted from anti-aliasing pixels to distances,
http://www.imagemagick.org/Usage/morpho ... anti-alias
But I have not done the reverse.

WARNING: colors may be in non-linear sRGB colorspace, but alpha should always be linear.
Of course compositions involving anti-aliasing pixels should be performed in a linear colorspace too.