Aliasing for 45 degree edge
Aliasing for 45 degree edge
Hello everyone.
I have been experimenting with the -distort -filter point and noticed some interesting results when output image contains is 45 degree angle. Given that edge is 45 degrees, I would expect the edge to be precisely 1 pixel step pattern. I noticed that one edge is usually as expected but the other is usually a different repeating pattern.
The image shown has been created in Photoshop, enlarged to signal pixel level. I simply created a black square and rotated 45 degree with nearest neighbour interpolation. Just as with ImageMagick distort, I noticed the same result with the edge...not perfect single step pattern on all edges.
Cam someone explain why a 45 degree angle would not be single pixel step pattern throughout the edge?
I have been experimenting with the -distort -filter point and noticed some interesting results when output image contains is 45 degree angle. Given that edge is 45 degrees, I would expect the edge to be precisely 1 pixel step pattern. I noticed that one edge is usually as expected but the other is usually a different repeating pattern.
The image shown has been created in Photoshop, enlarged to signal pixel level. I simply created a black square and rotated 45 degree with nearest neighbour interpolation. Just as with ImageMagick distort, I noticed the same result with the edge...not perfect single step pattern on all edges.
Cam someone explain why a 45 degree angle would not be single pixel step pattern throughout the edge?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Aliasing for 45 degree edge
Perhaps because the interpolation is not giving exactly integer values and so it picks the nearest value.
What was your exact set of commands to get that image? Was this image created in Photoshop or IM? Does a PS processed image show the same?
What is your IM version and platform? Please always provide that since syntax may vary.
What was your exact set of commands to get that image? Was this image created in Photoshop or IM? Does a PS processed image show the same?
What is your IM version and platform? Please always provide that since syntax may vary.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Aliasing for 45 degree edge
I might be able to explain something, if I knew what that "something" was. With a couple of guesses at your IM command, I can't reproduce your result.josephs wrote:Just as with ImageMagick distort, I noticed the same result with the edge...not perfect single step pattern on all edges.
Cam someone explain why a 45 degree angle would not be single pixel step pattern throughout the edge?
Please also say what version IM you used, on what platform.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Aliasing for 45 degree edge
Also perhaps it is because -distort resize is quite different from -resize. See http://www.imagemagick.org/Usage/resize/#distort for its limitations
Re: Aliasing for 45 degree edge
I'm using version 6.9.3-3 Q16 x64 2016-02-06. It was not related to a specific project just some observations as I was learning the distort and trying different things. All my experimenting used only the following.
-virtual-pixel transparent -filter point -interpolate nearest -distort BilinearForward
As far as I can see if your transform any image using the above you will get same results if output image has 45 degree edges.
-virtual-pixel transparent -filter point -interpolate nearest -distort BilinearForward
As far as I can see if your transform any image using the above you will get same results if output image has 45 degree edges.
Re: Aliasing for 45 degree edge
I'm using Windows in case that is relevant.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Aliasing for 45 degree edge
Not so, for example, using v6.9.5-3:josephs wrote:As far as I can see if your transform any image using the above you will get same results if output image has 45 degree edges.
Code: Select all
convert -size 200x200 xc:Black -virtual-pixel White -filter Point -interpolate nearest +distort SRT 1,45 x.png
snibgo's IM pages: im.snibgo.com
Re: Aliasing for 45 degree edge
Hi. Thanks for the replies. The issue was actually related to the how I was using coordinates to distort the image to create 45 degree output. I was using a combination of pixel and image coordinates using exact values and %h. The result was that the output was off just enough to present the issue. All is good now!
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Aliasing for 45 degree edge
Answering the original question, which is a core aspect of raster graphic processing.
Its is sort of the elephant in the room, and as such why its seemed to have been ignored...
The BEST 45 degree edge consists of full pixels, empty pixels, and a line of half-full pixels (50% grey in linear RGB) or anti-aliasing pixels.
If you do not have those partial pixels, you will have a overly sharp, stair-cased line. That is, it is highly aliased! Thus the need for anti-aliasing!
Its is sort of the elephant in the room, and as such why its seemed to have been ignored...
Because at a 45 degree angle a perfect edge will ALWAYS partially cover some pixels. That is you can not get a edge that can only included whole pixels. Only a horizontal and vertical edge can do that!
The BEST 45 degree edge consists of full pixels, empty pixels, and a line of half-full pixels (50% grey in linear RGB) or anti-aliasing pixels.
If you do not have those partial pixels, you will have a overly sharp, stair-cased line. That is, it is highly aliased! Thus the need for anti-aliasing!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Aliasing for 45 degree edge
FYI for others...josephs wrote: ↑2017-03-15T21:03:23-07:00 Hi. Thanks for the replies. The issue was actually related to the how I was using coordinates to distort the image to create 45 degree output. I was using a combination of pixel and image coordinates using exact values and %h. The result was that the output was off just enough to present the issue. All is good now!
Image Coordinates vs Pixel Coordinates
http://www.imagemagick.org/Usage/distor ... oordinates
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/