53

I have a flat design (well, it's supposed to be), but these black and white lines between the shapes are so annoying... [no stroke] take a look:

Problem

See these lines between two overlapping rectangles? How can I fix it? (I created this with Photoshop, but there is the same problem using Paint.net and Adobe Illustrator) Is it something with the color? Or am I seeing too much? :P

  • I think the key here deciding on if this is Mach band or something else is the asymmetry: "as you can see, the right side of the rectangle overlapped by 1 px (as you stated) while the left side didn't". Mach bands should appear symmetrically on both sides. – Elmo Allén Nov 17 '14 at 16:58
  • 1
    I zoomed way in (to 25600%) so it is definitely a subpixel affect. Incidentally I only see the artefacts on 1 out of 3 monitors. The other two look primo sharpo!! So its definitely dependant on the pixel construction of your monitor. – Octopus Nov 17 '14 at 23:44
  • 1
    @Octopus: What brand monitors? That is my next purchase, and I would love to buy something that is objectively higher quality. – dotancohen Nov 20 '14 at 9:22
90

As Elmo Allén correctly notes, this is neither an optical illusion not a bug in your graphics editor, but an effect caused by the monitor technology you're using.

Specifically, on a typical modern TFT-LCD computer screen, each pixel is actually composed of three separate subpixels arranged side by side, respectively colored reg, green and blue:

Pixels on a TFT screen

Each of these subpixels can only produce one of the primary colors of light, but, since they're very close together, their colors blend together when you look at them, producing the illusion of solid color.

For a white (or gray) pixel, all the subpixels are equally illuminated. By adjusting the intensity of the different subpixels relative to each other, different colors can be produce. At the extreme, for a pure red, green or blue pixel, only the subpixels producing that color are turned on. Thus, your red–green–red stripe will, at the subpixel level, be rendered something like this:

Red-green-red stripe on a TFT screen

Here, you can begin to see what's going on: usually there's a gap of two dark subpixels between each lit one, but at the boundaries between the colors, the gap is either three subpixels (creating a dark band) or just one (creating a light one).

Of course, the effect is more obvious when the colors of nearby subpixels are blended together, as normally happens when you look at the screen:

Red-green-red stripe on a TFT screen, blurred

Here, I've applied only a moderate amount of blur, simulating what you might see if you e.g. looked at your screen through a magnifying glass. (Try it!) The dark band at the left-hand boundary is obvious here; the bright band at the right-hand boundary doesn't show up as clearly, but it would become more noticeable if the image was blurred further.

Of course, you don't have to trust these simulated images. Instead, let me include a couple of close-up photos I took of my laptop screen, showing the image in your question, with a cheap digital camera:

Photo of laptop screen showing red/green color boundary
Photo of laptop screen showing green/red color boundary

As in the simulated image, the dark line is very obvious; the bright line is less so, perhaps because there's still one dark subpixel between the lit ones, so there isn't such a clear single intensity peak.

What can you do to fix this?

In principle, this effect is something that your monitor could automatically compensate for, e.g. by detecting such problematic transitions and letting the colors bleed slightly into each other to soften the transition. This would add more complexity and cost, though, which is why most monitor manufacturers don't bother.

You can, however, achieve the same result yourself by adding a narrow stripe of an intermediate color (e.g. yellow, for red and green) between such highly contrasting color fields. The color of this stripe should approximately match the average luminance of the surrounding colors, taking display gamma into account.

  • 2
    I dont think that compensating would really affect cost all that much (~1 euro per panel tops). Considering old amiga days they did something similar. Its more like the problem is somewhat rare an you dont want problems with your sharpening/adaptive adjustments for nearly no gain. Just a good reminder that technology is full of tradeoffs and you need to be aware of some of them. +1 Hyvät kuvat kuitenki. – joojaa Nov 17 '14 at 23:21
  • 2
    Is adding intermediate colors actually done in practice? – Lilienthal Nov 20 '14 at 15:36
  • 1
    @Lilienthal: I've never seen it; then again, the whole point is that you're not supposed to see it. I suppose one reason why the need rarely arises in practice is that most designers tend to avoid putting such strongly contrasting pure colors next to each other anyway. – Ilmari Karonen Nov 20 '14 at 15:41
35

It is hard to make exactly what everyone sees here, because everybody has their own display to see the image. On my monitor, if I squint, I could see a very thin black line between the left red rectangle and the green middle rectangle. And in contrast, between the right red and middle, I see a very thin white line. Basically, I understand the original poster means they see this (exaggerated):

Description of the problem: a black or white line between adjacent rectangles, exaggerated.

These aren't Mach bands, as suggested in the question comments. Mach bands are not born in between different-chromed colours, but instead between different-lighted colours (e.g. between two shades of gray). A very faint Mach band is created in the red rectangle's right side, because full red (RGB 255-0-0) is slightly less bright than full green (RGB 0-255-0) on my monitor (and on all sRGB monitors as well). (Even though the colours the original image are not pure Red or Green, the difference in their percepted lightness is approximately same.) Basically, Mach bands show like this (again, highly exaggerated):

Illustration of Mach bands, exaggerated.

But Mach bands cannot create white or black thin lines. They only create a slight difference in observed brightness on a wide area. And Mach bands are always symmetric: red-to-green is same as green-to-red. But this is asymmetric: other boundary is black and other is white.

Instead, what visual artifact we see here is because of LCD sub-pixel arrangement. The most usual arrangement is Red-Green-Blue from left to right. So between each full red pixel there are a turned-off green subpixel and a turned-off blue subpixel. Between a full red pixel and a full green pixel, instead, there are three turned-off subpixels: green, blue, and red. This creates an effect of a thin black line between the red and green. As in the image below:

Sub-pixel representation of red colour meeting green colour.

Now on the other side of the green rectangle, there is first a lit green subpixel, turned-off blue subpixel and then a red one. Now between the lit green and red subpixels there is only one black subpixel. This creates an effect of a very thin bright line running in between the green and red boundary. As in below:

Sub-pixel representation of green colour meeting red colour.

To see the subpixels on your monitor, you'll probably need a magnifying glass. Norman human eyesight cannot focus on so close distance where you would see the separate pixels. However, it is very good in spotting that slight brightness difference.

Now, to prove the theory correct, you could add e.g. a 1 px wide line of RGB 128-255-0 between the left red rectangle and the green rectangle and see if the black line fades out, because this adds some green subpixel light before the gap. Also you could try e.g. a 1 px wide RGB 85-85-0 between the green and right red rectangle, to dim the subpixels a little. Unfortunately, this cannot be used in actual design, because firstly it depends on the red-green-blue subpixel arrangement and at the same time makes the colour border a little bit smudged.

Furthermore, there is a possibility of a screen sharpening algorithm taking place. Basically monitor sharpening makes all colour edges more prominent, adding white to the brighter side of the edge and dimming to black on the darker side. This is much like the Mach band effect, but much narrower and usually more prominent. This can be found out by adjusting the display's sharpness setting (hopefully possible) and seeing if the effect is reduced.

  • 2
    yes that makes sense, however does not account for all of the effects, but yes now that i look in a 2 diferent monitors with a known different order the effect is in fact inverted. However i dont see the color uneveness on the primary monitor, which may be due to the insanely good quality of the monitors picture elements. The only thing i see is the mach bands. Ps to test this turn monitor upside down. – joojaa Nov 17 '14 at 15:37
  • ah or indeed that the elemebts are stochastically scrambled to counter this problem – joojaa Nov 17 '14 at 15:45
  • Anyway, the OP @candh talks about 1px wide overlapping. Mach bands should never be this narrow. (Anyway, they cannot even be defined in the sense of pixel, because they form in the brain. Subpixel artifacts form on the screen.) Still, withouth candh elaborating more on what he exactly sees, we are stuck with finding the correct solution. (With my reputation, I can't comment to the question yet.) – Elmo Allén Nov 17 '14 at 15:47
  • 2
    @joojaa, of course noise would abate the straight-line effect of subpixels, but it would throw the baby with the bathwater, because the straight sharp line would not look so sharp any more. I don't think there is any good way to combat this or actually any reason to. On modern displays the effect is already minuscule, and now with the HiDPI displays slowly coming mainstream even on desktop computers, it matters even less. Furthermore, very large chroma contrasts are very seldomly used, and this doesn't affect lightness contrast at all. – Elmo Allén Nov 17 '14 at 17:10
  • 2
    On my R,G,B monitor, I reduced a lot the visual artefact by increasing/decreasing the total of the two boundary pixels by 1/6th (total 1/3rd, accounting for the shift-by-1/3-of-a-pixel). More precisely: 1 0 0|1 0 0|1 x 0|x 1 0|0 1 0|0 1 0: if you set the two x components to 1/6 instead of 0, you avoid the black band effect. And in 0 1 0|0 1 0|0 y 0|y 0 0|1 0 0|1 0 0: you need y set to only 5/6 to avoid the white band effect. (The values 1/6 and 5/6 should probably be refined by taking into account the eye's level of perception.) – Armin Rigo Nov 17 '14 at 18:13
4

This is the nature of the colors when they come together, The human eye tends simplification to clarify things .. and the optical illusions caused by our perception of colors.

this phenomena which is called "Mach Bands Illusion" appears with any two color different in Value. not in the hue nor the saturation. and my attached diagram show that the same illusion occur in gray colors. the lighter gray will be more lighter comparing to the darker one in the middle and the middle gray appears lighter beside the edge of the right dark gray at the right. And so one.

enter image description here

if it is important to you so you have two options.

  1. to choose two colors that have the same black ratio this will insure to decrease the illusion
  2. you can "fool the eye" by adding a gray tiny line in between the two color that have the average gray of the two grays in those colors. see the result hereunder. you may recognize that the top strip is less in the illusion that the bottom one.

the top strip is less in the illusion

this is zoomed version with the tiny gray line.

  • 11
    This is incorrect. The first diagram (red-green-red) doesn't correspond to the second one (light grey-mid grey-dark grey) because the two reds are the same colour. If it was about brightness, the line graph would be symmetrical, like this --\|\--/|/--, and you'd see either a black band at both the red-green interface and the green-red one, or a white band at both. – David Richerby Nov 17 '14 at 16:48
  • 5
    This is really easy to disprove. If you have a laptop and see the black and white lines then turn your laptop upside-down. You'll find the black line on the right instead of the left. – slebetman Nov 18 '14 at 14:52
  • 3
    @hsawires: The idea is to prove something scientifically. Turning the laptop upside down and seeing your theory dissipate entirely is most certainly a valid disproof. You can't just hand-wave it away saying "you can't prove or disprove illusions"; what nonsense! – Lightness Races with Monica Nov 20 '14 at 11:00
  • 1
    @hsawires: Anyway, by turning the screen upside down, if it hadn't been for the fact that this reverses the order of the diodes that creates the different colors on the screen, it wouldn't have made any difference to how the image is perceived, because the image is symmetric. Otherwise you could by looking at the Mach band effect determine whether the screen had been rotated or not, which doesn't make any sense. The fact that the image isn't perceived identically means that something else is must be happening, which is due to the subpixel structure Ilmari and Elmo both describe. – HelloGoodbye Nov 22 '14 at 15:10
  • 1
    To support @HelloGoodbye, our trusty friend Wikipedia (en.wikipedia.org/wiki/Mach_bands) has this to say: "The illusion is independent of orientation." – Nelson Rothermel Dec 15 '14 at 19:02
0

I can't be certain, but if you are wearing glasses, that is where the problem will lie. You're most likely seeing a chromatic aberration, in which the reds and the greens are separating.

The thicker your glasses the more pronounced the effect will be. Try turning your head and watch the color blocks move -- as you move towards the edge of your glasses, your glasses will be thicker, and thus cause a greater separation.

  • 6
    It's not chromatic aberration. Any half-way competent pair of glasses will not show chromatic aberration when looking straight at a computer monitor. – David Richerby Nov 17 '14 at 22:36
  • There is absolutely an aspect of chromatic aberration here. Just adjusting the angle I'm looking at the monitor at makes the black and white bands change size. And whilst this effect is more pronounced with glasses, it's still present without glasses - your eyes have imperfect lenses too! Ignoring that pure primary colours will have this effect is missing part of the story. – David Sainty Nov 20 '14 at 20:45
  • @Sainty As Ilmari's answer shows, this is about sub-pixel spacing on the monitor. If you move your head to the side, the apparent spacing of the sub-pixels changes so the effect changes. And how would chromatic aberration produce black? Are you proposing that the aberration is so severe that the light's frequency changes to be outside the visible region of the spectrum? – David Richerby Nov 22 '14 at 10:41
  • @Richerby: Based on candh's response, and some more detailed investigation on my part, this is not the effect he was seeing. Chromatic aberration does exist, though, and does create black lines -- the red will shift one way and the green the other; think prisms and how they separate colors. The remaining part will appear black, though to my eyes (when I wore glasses) it looked more like the red was "floating" above the screen. – user295691 Nov 25 '14 at 16:24
0

This thread on Adobe's forum has a good bit on where the "Align to pixel grid" options are.

If I remember correctly, this can also be enabled document-wide via the File > New dialog (at the very bottom of the box).

Either these hard-core monitor experts are correct, or you just have a discrepancy created by the vector not aligning to the pixels on your monitor correctly. This is precisely why so many people are excited about this little check box being added to Illustrator.

  • 3
    The vectors are aligned correctly. To check that you'll have to just copy-paste the image to Photoshop or to any image editor and zoom in. There's no antialiasing between pixels and no mid-tone pixels at all. – Elmo Allén Nov 17 '14 at 22:03
-2

This might be due to color interaction. Red and green are complementary colors and when placed side by side seem to create a black/dark line that seems like an overlap. You could read and see more examples here.

Illustrator auto snaps shapes into place, so there shouldn't be any issue of overlap happening there.

  • 2
    If the phenomenon was purely because of our eyes, you'd see the same thing at the red-green boundary as you do at the green-red boundary. – David Richerby Nov 17 '14 at 18:15
  • Red and green, when placed side by side and viewed from a sufficient distance (e.g. looking at small pixels from a few feet away), would produce yellow, not black. – Jason C Nov 22 '14 at 23:13
-2

If you enable an option Align New Objects to Pixel Grid in the Transform window's option menu (the one in the top right corner of any option window), any new objects that you draw have the pixel-aligned property set by default. For new documents created using the web document profile, this option is enabled by default. For existing objects, you can turn off the pixel grid alignment by selecting Align to Pixel Grid in the Transform window itself (shown after ticking on More Options in the window's option menu).

The crisp appearance of pixel-aligned strokes is maintained in the raster output at a resolution of 72-ppi only. For other resolutions, there is a high possibility of such strokes producing anti-aliased results.

Objects that are pixel-aligned, but do not have any straight vertical or horizontal segments, are not modified to align to the pixel grid. For example, because a rotated rectangle does not have straight vertical or horizontal segments, it is not nudged to produce crisp paths, when the pixel-aligned property is set for it.

This Adobe's documentation tells it more broadly: http://helpx.adobe.com/illustrator/using/drawing-pixel-aligned-paths-web.html

  • 1
    which option, exactly ? – candh Nov 17 '14 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.