Extreme EWA Limits

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Extreme EWA Limits

Post by anthony »

While going through some IM examples on Distorts, and in particular the LAST example in
Viewing Distant Horizons
http://www.imagemagick.org/Usage/distorts/#horizon

The one that involves the traditional (and I found useless) checker board image pattern.
Image

I realised I never really explained how the EWA filters actually handle the extreme limits (highly elongated and large ellipses) that happen close to the horizon. Especially as this example image actually shows a 'cutoff' of the diagonal pattern as it gets closer to the horizon.

As such this is what I have added (appearing shortly on offical site), and am repeating here for discussion.
This last image also shows a 'cutoff' point close to the horizon where ImageMagick decided that it was not worth attempting to determine the appropriate color for a pixel (with consideration of the current virtual pixel setting), but short-circuit the EWA algorithm and use the average color of the whole image. It is only visible in this image because of the large scale diagonal pattern of color that is present in the image.

The average color of an image is only calculated once per distion operation, and only when needed. By using it ImageMagick saves a huge amount of time calculating colors close to the horizon when typically the result will be the images average color. This happens when either the ellipse become so elongated as to exceed floating point limits, or the number of sampling pixels (bounding parallelogram of elipse) becomes 4 times larger than the input source image. This is currently not user setable.
Note at the time I tried a number of settings and found 4 times image size for the parallogram area (of which 71% of the pixels actually form the sampling ellipse) to be reasonable.

Ellipses generated in this area of the destination image tend to be fairly large or impossibly large (by an order of magnitude) from one pixel to the next. so I did not see a great deal of difference betwen using a value 4 times image size or 16 times image size (maybe one or two pixels effected at most). As such I never really considered that someone may actually want to modify that limit.

Note that few people view such distortion 'horizons', and no one has ever commented on these limit effects. But it was visible so I thought I better comment on it now.

For code divers the appropriate area is in "resampling.c" around line 1200 (look for the value "4.0" it is only hardcoded twice in this source code file. Values of Uwidth and Vlimit is as per the ellipse diagram associated with this code, as it is also this area that implements the ellipse math.
Image
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply