pytroll / pytroll/aggdraw

Line anti-aliasing issues due to missing sRGB mishandling

Open
#65 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug question
Dominant language
C++
Stars
107
Forks
45
Avg merge
13h 41m
Merged PRs (30d)
7

Description

Hi,

I just started using aggdraw, and it definitively draws nicer lines than PIL for my application (opacity and antialiassing does help), but I noticed still imperfection and possibly a bug:

dump

Be sure to open it and view at 100% scale.

The issue is visible as uneven luminosity of the lines. I.e. if you look at the top center, and then count 3 or 4 lines to the right, it looks to be oscillating in brightness.

I am not talking about a Moiré pattern that appears in the center, that is somehow expected, but possibly is related partially. I am talking about straight slightly diagonal lines far from the center.

It feels like maybe the sRGB is not used correctly? Which is a bit strange, as I see there is support for gamma, linear and sRGB in the aggdraw.

# Python 3.8.1
from PIL import Image, ImageDraw  # Pillow 6.2.1
import aggdraw  # Version 1.3.11
w, h = 1024, 1024
img = Image.new("RGB", (w, h))
img1 = aggdraw.Draw(img)
img1.setantialias(True)
pen = aggdraw.Pen("white", 1.0, opacity=127)

img1.line(xyxyxy, pen)
# ...

img1.flush()
img.save("dump.png")
img.show()

With opacity=255 effect is visible even more:

dump

dump

When drawing a similar type of lines (width and angle) for example in Inkscape, I see much more uniform luminance and the oscillations are there, but essentially invisible.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied Python example with aggdraw 1.3.11, including the diagonal lines and the different opacity values. Start by tracing the antialiasing and gamma behavior exposed by the example; done means determining the cause of the uneven luminance and producing visibly more uniform lines without the reported oscillations.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.