Why are image coordinates rounded to integers?

Hi,

Mike Fitzgerald reported bug #2832896 and has been investigating its
causes:

https://sourceforge.net/tracker/?func=detail&aid=2832896&group_id=80706&atid=560720

The problem is that images are not drawn at exactly the same coordinates
as other artists, so markers drawn on top of images are slightly off in
pdf and eps output. Apparently this can be fixed, at least to some
degree, by removing the round(...) operations from

    renderer.draw_image(gc, round(l), round(b), im)

in _AxesImageBase.draw and making a slightly more involved change in
AxesImage.make_image (the details are in the bug report). I haven't had
time to investigate what this does to other backends, but I imagine the
rounding would be necessary for raster backends.

Can someone who is more familiar with the image machinery comment on the
matter? Do we need some kind of vector/raster indication in the backends,
in addition to the get_image_magnification method?

···

--
Jouni K. Sepp�nen
http://www.iki.fi/jks

I think I agree that the rounding is necessary for raster backends, but is in the wrong place -- it should be in the backend itself.

It's needed for Agg to prevent "gaps" between the image and axes rectangle. The axes rectangle is always drawn pixel-aligned using "round", so if the image is drawn by truncation to integers, there will be small gaps for certain values. But yes, it makes sense to *not* do any rounding or truncation in the vector backends.

I'll commit something for this -- on the trunk, because it feels a bit too pervasive for the branch.

Mike

Jouni K. Sepp�nen wrote:

···

Hi,

Mike Fitzgerald reported bug #2832896 and has been investigating its
causes:

https://sourceforge.net/tracker/?func=detail&aid=2832896&group_id=80706&atid=560720

The problem is that images are not drawn at exactly the same coordinates
as other artists, so markers drawn on top of images are slightly off in
pdf and eps output. Apparently this can be fixed, at least to some
degree, by removing the round(...) operations from

    renderer.draw_image(gc, round(l), round(b), im)

in _AxesImageBase.draw and making a slightly more involved change in
AxesImage.make_image (the details are in the bug report). I haven't had
time to investigate what this does to other backends, but I imagine the
rounding would be necessary for raster backends.

Can someone who is more familiar with the image machinery comment on the
matter? Do we need some kind of vector/raster indication in the backends,
in addition to the get_image_magnification method?

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA