Skip to content

Fix white gap between image and border#219

Merged
cfarrow merged 3 commits into
masterfrom
fix/image-draw-area
Oct 2, 2014
Merged

Fix white gap between image and border#219
cfarrow merged 3 commits into
masterfrom
fix/image-draw-area

Conversation

@cfarrow
Copy link
Copy Markdown

@cfarrow cfarrow commented Sep 30, 2014

Fixes #218. I have manually tested this with the 'qt4.image', 'qt4.qpainter', and 'wx.image' backends on OSX.

I seen elsewhere the center-pixel adjustment used here, but I am uncertain about the details of why it is needed. For example, the ColorBar does not need this adjustment. (Is there something wrong with the kiva.agg.GraphicsContextArray used in the ImagePlot?)

@rkern, would you mind reviewing this?

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.01%) when pulling 0557606 on fix/image-draw-area into 4961533 on master.

@cfarrow
Copy link
Copy Markdown
Author

cfarrow commented Sep 30, 2014

I have manually verified this on Windows as well.

@rkern
Copy link
Copy Markdown
Member

rkern commented Oct 1, 2014

Can you do a quick test with a checkerboard pattern (i.e. alternating pixels black and white)? The last time I fixed this kind of thing elsewhere, that was a good visual check (ha ha) to determine if I didn't make another fencepost error. The math looks correct, though.

@cfarrow
Copy link
Copy Markdown
Author

cfarrow commented Oct 1, 2014

Good call on the test image. I was unnecessarily increasing the image size. The test image is below. There green inner border should be visible around the entire perimeter, and it is.

screen shot 2014-10-01 at 8 32 08 am

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.0%) when pulling 5d2bd65 on fix/image-draw-area into 4961533 on master.

Comment thread chaco/image_plot.py
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true for all GraphicsContexts?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empirically, it is true for the GraphicsContextArray. I rooted around the kiva source code to find a definitive answer, but gave up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to try other GCs to be sure that this is the right place to do this adjustment. The different backends can behave differently, albeit unintentionally. We have been fighting these off-by-(one/half) issues for a long time.

@rkern
Copy link
Copy Markdown
Member

rkern commented Oct 1, 2014

Sorry, I meant that literally every pixel should alternate. Each square should be exactly one pixel. If you got the boundaries correct, then you will not see any aliasing. Otherwise, you will see some neat Moiré effects.

@cfarrow
Copy link
Copy Markdown
Author

cfarrow commented Oct 1, 2014

I started going in that direction, but quit because the aliasing was making things difficult. :)

I'll try that.

@cfarrow
Copy link
Copy Markdown
Author

cfarrow commented Oct 1, 2014

This fix improves the visual appearance of image plots. The story for other graphics context varies (see below). The conclusion is that this improves on-screen image plots and off-screen renderers are no worse off with this change.

kiva.agg.GraphicsContextSystem

Before fix with no image scaling:
ss_unscaled

After fix with no image scaling:
ss_unscaled

With image scaling (before):
ss_scaled

And after:
ss_scaled

chaco.svg_graphics_context.SVGGraphicsContext

These were converted to png using qlmanage.

No scaling (before):
image_w481_h401_unscaled svg

No scaling (after):
image_w481_h401_unscaled svg

With scaling (before):
image_w481_h401_scaled svg

With scaling (after):
image_w481_h401_scaled svg

chaco.plot_graphics_context.PlotGraphicsContext

No scaling (before):
image_w481_h401_unscaled

No scaling (after):
image_w481_h401_unscaled

With scaling (before):
image_w481_h401_scaled

With scaling (after):
image_w481_h401_scaled

@cfarrow
Copy link
Copy Markdown
Author

cfarrow commented Oct 1, 2014

The script I used to generate the data is here.

@rkern
Copy link
Copy Markdown
Member

rkern commented Oct 2, 2014

The Quartz backend was the one I was most concerned with since that is the one that has tended to be off-by-half/one compared to the Agg backend. However, it also looks improved. 👍

@cfarrow
Copy link
Copy Markdown
Author

cfarrow commented Oct 2, 2014

Thanks!

cfarrow pushed a commit that referenced this pull request Oct 2, 2014
Fix white gap between image and border
@cfarrow cfarrow merged commit 0337d72 into master Oct 2, 2014
@cfarrow cfarrow deleted the fix/image-draw-area branch October 2, 2014 13:06
tonysyu added a commit that referenced this pull request Nov 5, 2014
Conflicts:
	chaco/image_plot.py

Hopefully, the changes from PR #219 were integrated correctly.
tonysyu added a commit that referenced this pull request Nov 5, 2014
@tonysyu tonysyu mentioned this pull request Nov 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image plots have white gap between image and border

4 participants