From a binary mask it is possible to generate an anti-aliased stroke using an exact distance transform:
Anti-aliased stroked mask using distance transform
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Anti-aliased stroked mask using distance transform
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.
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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Anti-aliased stroked mask using distance transform
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%).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.
Photoshop uses linear color space for RGB when performing internal calculations (like anti-aliasing).And no there is no internal function for this as yet. PS: anti-aliasing pixels may have been generated in a linear colorspace
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Anti-aliased stroked mask using distance transform
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.
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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/