Slashdot Mirror


Scaling Algorithm Bug In Gimp, Photoshop, Others

Wescotte writes "There is an important error in most photography scaling algorithms. All software tested has the problem: The Gimp, Adobe Photoshop, CinePaint, Nip2, ImageMagick, GQview, Eye of Gnome, Paint, and Krita. The problem exists across three different operating systems: Linux, Mac OS X, and Windows. (These exceptions have subsequently been reported — this software does not suffer from the problem: the Netpbm toolkit for graphic manipulations, the developing GEGL toolkit, 32-bit encoded images in Photoshop CS3, the latest version of Image Analyzer, the image exporters in Aperture 1.5.6, the latest version of Rendera, Adobe Lightroom 1.4.1, Pixelmator for Mac OS X, Paint Shop Pro X2, and the Preview app in Mac OS X starting from version 10.6.) Photographs scaled with the affected software are degraded, because of incorrect algorithmic accounting for monitor gamma. The degradation is often faint, but probably most pictures contain at least an array where the degradation is clearly visible. I believe this has happened since the first versions of these programs, maybe 20 years ago."

76 of 368 comments (clear)

  1. Oh calm down.. by Anonymous Coward · · Score: 4, Insightful

    Photographs scaled with the affected software are degraded, because of incorrect algorithmic accounting for monitor gamma.

    Seriously!

    I have a theory on why this has gone unnoticed for so long, but I'll keep it to myself...

    1. Re:Oh calm down.. by Anonymous Coward · · Score: 2, Informative

      Yes because everyone in the world who posts to the internet is a native English speaker.

      Having read that I am willing to be English isn't his first language

    2. Re:Oh calm down.. by nollidge · · Score: 3, Funny

      Having read that I am willing to be English isn't his first language

      I am willing to be Mavis Beacon.

    3. Re:Oh calm down.. by imakemusic · · Score: 5, Funny

      He seems to take it seriously.

      Probably a gamma nazi...

      --
      Brain surgery - it's not rocket science!
  2. Monitor gamma? by Yvan256 · · Score: 2, Insightful

    To display the pictures, it makes sense to use the monitor gamma. But to actually modify the data using that information which is probably flawed in 99.9999999% of cases? That's just wrong.

    1. Re:Monitor gamma? by Trepidity · · Score: 2, Interesting

      In some cases at least it seems like the primary purpose of scaling is to display the images immediately, in which case it seems like the gamma should be accounted for. For example, when browsers rescale images, it's an unexpected result if they change the perceived brightness while doing so--- shouldn't the browser's scaling be done in the same brightness space as the one it intends to use to display the images?

    2. Re:Monitor gamma? by theskipper · · Score: 5, Funny

      Excellent point. Just to be safe though, I'm going to take another look through my porn crypt to see if that's true.

      BRB.

    3. Re:Monitor gamma? by poetmatt · · Score: 3, Interesting

      The responses that they post are also inaccurate it seems.

      From

      All four images in this page are the same one but your browser was instructed to scale it. The one below is scaled 1:2. On Opera and some versions of Internet Explorer it will show a gray rectangle.

      meanwhile, I see a grey rectangle in firefox, and I still don't get what that signifies.

    4. Re:Monitor gamma? by evanbd · · Score: 5, Informative

      The data in the pictures is not linear data. It assumes that it will be displayed on a system that introduces a gamma of 2.2. (If your display system does not do that physically, it should correct for this.) That is, a gray 127 should not display as halfway between a white 255 and a black zero, in terms of light output. (It should *appear* halfway between them visually, because your eyes aren't linear — that's (part of) why gamma is in use in the first place.) So, a checkerboard pattern of white / black squares will have half the luminosity of the white squares. When scaling down, software will turn it into a bunch of gray pixels. But they should be gray pixels of value 186, not 127.

      The page is not well written, but his example images make the issue very clear. It's not about your monitor gamma; it's about the "standard gamma" that all image files assume your monitor has.

    5. Re:Monitor gamma? by evanbd · · Score: 5, Informative

      Actually, any well-specified file format will specify the gamma. Not all allow you to set it per-file, but they do specify it. Normally this is a line in the spec that reads something like "color values use the sRGB color space" or similar — which specifies a gamma of 2.2 (roughly). And sRGB with it's nearly 2.2 gamma has become so standard that assuming anything else (in the absence of a clear spec) would be idiotic.

    6. Re:Monitor gamma? by reub2000 · · Score: 2, Informative

      Depends. Standard sRGB used in a jpeg file stores the data in non-linear format. If data was stored in a linear format, then a disproportionate part of the gamut would be in the highlights. On the other hand, a raw file contains the data in a linear format.

    7. Re:Monitor gamma? by X0563511 · · Score: 2, Insightful

      Here:
      http://img43.imageshack.us/img43/2586/scalerbug.png

      Look at the third set of images. Had this bug not been present, they should have been nearly identical. As you can see, in my case, they are radically different.

      As the text reads:

      (dali picture)
      All four images in this page are the same one but your browser was instructed to scale it. The one below is scaled 1:2. On Opera and some versions of Internet Explorer it will show a gray rectangle. KDE Konqueror, Firefox and SeaMonkey will display it either pink or green or half-green, half-pink:

      (smaller dali or grey box)
      (mine draws in grey, despite using Firefox)

      Below it is scaled down 1:4. The right one is one pixel wider and higher than the left one. Some browsers display them quite differently:

      (two images, differing if you have the bug)

      --
      For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
    8. Re:Monitor gamma? by DocHoncho · · Score: 2, Insightful

      meanwhile, I see a grey rectangle in firefox, and I still don't get what that signifies.

      It means the scaling algorithm in your web browser and other commercial softwares is disastrously broken. Duh, didn't you RTFA?

      --
      Celebrity worship is a poor substitute for Deity worship and costs more to boot.
    9. Re:Monitor gamma? by Anonymous Coward · · Score: 5, Funny

      Well?

    10. Re:Monitor gamma? by Idarubicin · · Score: 5, Informative

      It seems crazy to me to embed a particular Gamma value into an image. ...In fact it seems so crazy I must be missing something. Am I?

      The article actually touches on this point. The sensitivity of the human eye isn't linear. If you use a linear scale to store luminosity information for an image, you waste a lot of bit depth at high luminosities - the eye has difficulty distinguishing between very bright and very bright plus a little tiny bit. On the other hand, the eye is very good at telling the difference between very dark and black. You need a lot of finely-graduated steps at low luminosity or else your shadows get jaggy.

      If you uniformly (linearly) space out luminosities on an 8-bit (256-shade) scale, you store a lot of uninteresting information at the high end, and lose out on visible detail at the low end. A scale with gamma of 2.2 (typical these days) fits a full twenty-eight grey values between 0 and 1 on our hypothetical linear scale. To maintain that kind of luminosity resolution (down where it matters), you'd have to store an extra five bits on your linear scale. An extra sixty percent costs.

      --
      ~Idarubicin
    11. Re:Monitor gamma? by DeathElk · · Score: 5, Funny

      Well?

      Somehow I don't think you've given him enough time.

    12. Re:Monitor gamma? by Anonymous Coward · · Score: 2, Informative

      Yes, you are missing something. Human perception isn't linear either. Twice the amount of light does not look twice as bright. Our eyes see differences between dark tones more clearly. The result is that we need many more dark tones than light tones for an "evenly" distributed tone curve (which is a tone curve where two neighboring light tones appear to be the same brightness difference as two neighboring dark colors). A physically linear gradient has the perceptual half tone shifted close to the black point.

      One consequence is that if you store an image with linear gamma, you need more bits to cover the same dynamic range with the same minimal distance between two dark tones. You can immediately see the decrease in resolution for the dark tones when you create an 8-bit image with a black-white gradient in Photoshop and then convert this image to a color profile with gamma 1.0.

      So not only is the 2.2 gamma which is used in the sRGB standard a sensible choice for the display technology of yesteryear, it also makes better use of the allocated bits than a gamma 1.0 image would.

    13. Re:Monitor gamma? by iknowcss · · Score: 2, Insightful

      That or you gave him too much time, he got bored with the idea, and forgot about it. You didn't wait more than 4 minutes, did you?

      --
      Life is rarely fair. Cherish the moments when there is a right answer.
    14. Re:Monitor gamma? by rvw · · Score: 4, Informative

      meanwhile, I see a grey rectangle in firefox, and I still don't get what that signifies.

      Right-click the image, then click view image. You'll see the image full-scale, like the first image. Scaling it down 50% shouldn't make it gray.

    15. Re:Monitor gamma? by evanbd · · Score: 2, Informative

      They did exactly that. It's called sRGB, and these days (nearly) all monitors claim to follow it. Some have better color than others, but they're all nominally sRGB. The ones that don't follow sRGB are well-specified as doing something else (and expensive), and purchased by people that know what to do with them. The (somewhat) arbitrary standard is a gamma of roughly 2.2. Monitors that don't produce that naturally fake it with software (in the monitor, not the computer).

      The problem is that the computer software doesn't expect linear, when it comes to what color is what, because it never has been linear. Basically, 256 shades of brightness is enough — but only if they aren't linearly spaced. There's a huge difference between a gray that's 1% of the white luminosity and 0%, but you can't see the difference between 99% and 100%. Using a gamma curve fixes this, by roughly matching the apparent change in brightness per change in the brightness. So the whole toolchain is built around a gamma of roughly 2.2, except when it comes to things like image manipulation.

    16. Re:Monitor gamma? by grumbel · · Score: 3, Informative

      IMO, what it actually means is that the so-called image is deliberately designed to be as catastrophically horrible as possible when scaled down.

      Yes, the image is designed to exploit the bug in way that makes it very obvious that the scaling is wrong, but no, the gray rectangle is not the correct solution. The problem is that the browser or the image application assumes that the brightness is stored on a linear scale, while in reality its stored exponential one. Thus when you scale things or apply other filters the brightness will be messed up. In real photos it will be less noticeable then here, but it will still happen.

      The correct way would be to transform the image to a linear scale before applying the filter and then restoring it the exponential one for display. A simple example of how to do that in Gimp (using gausian blur instead of scale, but it is the same bug) would be this. The left image is the original from the article, the middle one is blur applied and the right one is applying a gamma of 0.5 to get it to a linear scale, then the blur and then a gamma 2 to restore it to its original scale. As you can easily see the right one looks like the left one, but blurred, while the middle one has no resemblance to the original, all the information got lost due to the bug. In practice you would need a higher bit depth to make this trick practical, as else you would end with banding artifacts.

  3. short version by Trepidity · · Score: 5, Informative

    Most scaling algorithms treat brightness as a linear space, so e.g. if you're doing downscaling to 1/2 the size in each dimension, collapse 4 pixels into 1 by setting the 1 pixel to the numerical average of the original 4 pixels. But, most images are displayed with an assumption that brightness is a nonlinear space, i.e. gamma > 1. Therefore, scaling changes the perceived brightness, an unexpected result.

    1. Re:short version by evanbd · · Score: 2, Informative

      Brightness by itself is not a function, so it can't be linear or nonlinear.

      Displayed luminosity is a function of the data value in the image file, which is what the OP meant by brightness. And it most certainly can be linear or non-linear.

      But then, I suppose you already knew that.

    2. Re:short version by omnichad · · Score: 2, Informative

      No, it's an algorithm that's just plain wrong. It's doing linear calculations on values that represent an exponential curve. It's a pretty big screw-up, made by almost everyone that designs resampling algorithms. Given that graphics people don't usually write software, it's not for them. People that try to blend colors 0 and 255 in software need to know that the result should be 186 and not 127.

  4. This isn't really a bug by Cassini2 · · Score: 3, Insightful

    This is only a bug depending on what you are doing with your final images. One of the things that annoys me is that many image manipulation programs do not actually explain the primitives they are using. The result can be a complete mess depending on what you are trying to accomplish. This article is an example of this effect.

    If you want photo-realistic results, then you need to take Gamma into account. However, very few file formats specify the Gamma, the grey level, the white level, the black level or the colour space of the original image. The result is that the many imaging operations must be wrong, as they can never be accomplished the way intended. For the most part, no one cares. This person found an application where people care.

    1. Re:This isn't really a bug by johndoe42 · · Score: 5, Informative

      But most people who use images expect to look at them eventually. And most image files are meant to be viewed at gamma 2.2. (Printer drivers will at least approximately emulate a gamma of 2.2, and LCDs emulate it intentionally.) If you view the image at some other gamma, you don't see quite what was intended.

      Another way of looking at it is that most standard image formats are stored with a nonlinear representation, and people who do math should realize that. For an untagged image, gamma=2.2 is a good bet. gamma=1.0 is a terrible bet.

      Of course, if we really want our software to do a good job, then that software should be aware that specifying colors like #FF0000 isn't a good idea -- they look very different on different screens. What the user probably meant to do was specify a particular color, which means that the numbers need to be marked with a color space. (For a great demo, get an HP LP2475w or some other good wide-gamut display, don't install a profile, and look at anyone's photo album. Everyone looks freakishly red-faced.)

    2. Re:This isn't really a bug by dimeglio · · Score: 2, Insightful

      Well if it's a 20 year old bug, it should be renamed to a feature and patented. "Method to produce photo realistic scaling without taking gamma into account."

      --
      Views expressed do not necessarily reflect those of the author.
    3. Re:This isn't really a bug by Waccoon · · Score: 2, Insightful

      I'm a cartoonist who runs a web comic, and I've known about this problem for years.

      To cut bandwidth, I have a set palette of indexed colors that I use as a base for each strip, and I pick a few extra colors to finish the anti-aliasing. It doesn't take as much effort or time as it sounds, and it cuts bandwidth considerably compared to a trucolor PNG, and doesn't have the artifacts of a JPEG.

      However, I noticed that when I reduced one of my strips in size, the brightness always changed, so when I applied my custom palette, I got weird results. I had to develop a masking technique to get around this.

      Photographers may not notice the problem, but for those who explicitly select a set palette, this has been a major issue for a while. It's too bad that graphics applications are so focused on photography that cartooning, especially coloring, is actually very difficult.

  5. HA! by TheDarkener · · Score: 5, Funny

    Well, I am SURE glad I'm using Linux^H^H^H^H^HWindows^H^H^H^H^H^H^HMac^H^H^Hshit.

    --
    It is pitch black. You are likely to be eaten by a grue.
    1. Re:HA! by moosesocks · · Score: 2

      Actually, according to TFA, Apple's built-in toolkits (used by Aperture and Pixelmator) seem to be immune to this bug. Photoshop ceased being a mac-like application a very long time ago.

      This is one of many reasons why creative professionals prefer macs over PCs --- and I'm not saying this as platform evangelism -- for one, you'd be hard pressed to disagree that Mac OS X's font-rendering, kerning, and anti-aliasing abilities are far superior to those provided by Windows when presented with side-by-side examples. It's lots of little things (many of which likely took the programmers a great deal of time to get right) that make the platform so nice to work with. Likewise, Adobe is quickly exhausting its remaining good will with the graphic design community, as recent Photoshop releases have declined significantly in quality, and have generally added little value to the application, as well as the abomination that is the Flash player.

      I haven't checked Win7 yet, but as of Vista, Windows still presented windows-3.1-style dialog boxes when adding fonts. Although this is a fairly superficial example, it provides a great example of Microsoft's general neglect of its existing codebases. Once a feature becomes "stable," it rarely if ever gets refined or tweaked in subsequent releases, while poorly-integrated features get piled on top (although it must be said that when Microsoft finally does choose to overhaul part of the UI, they generally do a pretty good job of it. IE7 and 8 are notable exceptions, and actually seem to have been made intentionally confusing -- even the KDE, GIMP, and Blender folks would struggle to make a UI so cryptic, inconsistent, and foreign-looking)

      --
      -- If you try to fail and succeed, which have you done? - Uli's moose
    2. Re:HA! by Korin43 · · Score: 4, Funny

      Well I tested the site in lynx and I didn't see any problems..

    3. Re:HA! by Mr2001 · · Score: 5, Informative

      This is one of many reasons why creative professionals prefer macs over PCs --- and I'm not saying this as platform evangelism -- for one, you'd be hard pressed to disagree that Mac OS X's font-rendering, kerning, and anti-aliasing abilities are far superior to those provided by Windows when presented with side-by-side examples.

      Mac OS X's font rendering is different , but calling it "far superior" is simply platform evangelism.

      OS X renders text so that the on-screen representation looks more like the printed representation, which is good for tasks like designing print advertisements (where you want to approximate the finished product as closely as possible). Windows takes liberties with the shape and spacing of on-screen text in order to line it up with the pixel grid, which is good for tasks like word processing and programming (where legibility on screen is more important). When you're used to Windows, Mac text looks blurry; when you're used to the Mac, I imagine Windows text looks thin and lanky.

      --
      Visual IRC: Fast. Powerful. Free.
    4. Re:HA! by Anonymous Coward · · Score: 2, Interesting

      > When you're used to Windows, Mac text looks blurry

      If you're programming in OS X and antialiased text annoys you, simply turn it off. Many editors support disabling it. Then you use a font, such as Monaco, that has been hand-tweaked at the right sizes for screen display and everything looks great, no blurriness.

    5. Re:HA! by Mr2001 · · Score: 3, Insightful

      Same with Windows font rendering. It is plainly inferior in all objective measures of typeface fidelity.

      Like I said, that's because fidelity isn't the primary goal. Windows goes out of its way to distort rendered text in order to align the character outlines with pixel boundaries.

      You might as well claim that donuts are "plainly inferior in all objective measures of bagel quality": they crumble apart when you try to spread anything on them, you can't buy them pre-sliced, none of them come with raisins inside... and that's all fine, because donuts aren't trying to be bagels.

      Subjective taste is subjective. Measurably fidelity is not, and handwaving about one being suited more to a given task than another doesn't make it so.

      Once again, you're assuming fidelity is the only goal of a font renderer, but that's not the case.

      When you take a font designed to be printed at 600 DPI and render it on a 96 DPI screen where each character is only a few pixels high, you face a tradeoff between fidelity and legibility. Apple decided to prioritize fidelity; Microsoft decided to prioritize legibility.

      The link you provided does not support that argument. Legibility is not a significant issue.

      Perhaps you missed this part: "Microsoft generally believes that the shape of each letter should be hammered into pixel boundaries to prevent blur and improve readability, even at the cost of not being true to the typeface."

      I personally find that working in Windows-based terminals on LCD monitors is far more straining than Mac-based ones or CRT monitors--the text is too sharp and loses distinctiveness.

      Fair enough. That's a matter of subjective taste.

      Others may be accustomed to something else, and that's fine, but it's flat-out falsehood to claim that grid priority makes for better onscreen legibility.

      At the point size in the article's example? Yes, you're right, both lines are legible.

      But at smaller sizes, it's a plain statement of fact: distorting characters to keep the lines distinct does indeed make for more legible text than accurately rendering them into amorphous blobs.

      --
      Visual IRC: Fast. Powerful. Free.
    6. Re:HA! by Anonymous Coward · · Score: 2, Insightful

      Like I said, that's because fidelity isn't the primary goal.

      Talk about changing the goalposts! This whole Slashdot story is about fidelity.

      You might as well claim that donuts are "plainly inferior in all objective measures of bagel quality"

      No, I'm pretty sure that font display is measured by fidelity to the creator's intention and design, just as photographic display is being measured by fidelity to accurate gamma values in TFA.

      Unless you're saying a typeface stops being a typeface when it shows up on a screen and becomes a...bagel, I think you're being evasive.

      The technical ins and outs of photo editing and display are all about fidelity; why would that not be the case with typeface rendering and display?

      Once again, you're assuming fidelity is the only goal of a font renderer, but that's not the case.

      And again, this is the most bizarre argument I've ever heard.

      That's like saying rendering the proper color gamut isn't the purpose of a monitor. Or that fidelity to the original source material isn't the purpose of speakers.

      Perhaps you missed this part: "Microsoft generally believes that the shape of each letter should be hammered into pixel boundaries to prevent blur and improve readability,

      No, but there's nothing to back up that statement of belief with reality, and in fact the results clearly show it not to be an issue. So the question is, if Microsoft had bothered to put some effort into proper rendering, would there be any meaningful loss of legibility?

      Empirically, the answer is obviously "no". As even that article points out, the determining factor is familiarity.

      Moreover, "blur" is not a bad thing. Smoothness of form is a critical element of successful typeface design. The ungainly reproduction of Microsoft's snap-to-grid shortcut ruins the flow of the best and most famous typefaces, hindering legibility.

      Why the article pretends that Microsoft's decision was anything other than lack of interest in fine-tuning is rather curious. It wasn't a conscious decision about legibility that led them here--it was instead a desire not to alienate what had become familiar by 1998 when ClearType started to take shape. Spolsky is neither a typographer nor a neutral commentator--he has an open preference for ClearType and no formal training in typeface design or in perceptual optics.

      When you take a font designed to be printed at 600 DPI and render it on a 96 DPI screen where each character is only a few pixels high, you face a tradeoff between fidelity and legibility.

      A false dichotomy.

      Pixel grid rendering is simply easier to implement; it is not quantifiably better in any way. Its distortion of precisely designed typeface lines interferes with the expert, the typeface designers and font engineers who not only carefully construct the aesthetics, but also the science.

      Microsoft commissioned fonts to work with their rendering technology to improve readability--had their system provided an overall advantage in actual legibility, such an effort would have been redundant. In fact, Verdana (and related fonts) exists to address the typographical shortcomings of ClearType.

      The fact of the matter is that the article provides nothing to suggest that legibility is improved with the Microsoft method, and provides both the empirical counterexample and the "Verdana paradox".

      But at smaller sizes, it's a plain statement of fact: distorting characters to keep the lines distinct does indeed make for more legible text than accurately rendering them into amorphous blobs.

      Setting aside for the moment the serious legibility issues of using small font sizes period for extensive work, that's the reason why subpixel rendering is disabled at a certain font size (default on OS X is 8pt;

    7. Re:HA! by Mr2001 · · Score: 5, Informative

      No, I'm pretty sure that font display is measured by fidelity to the creator's intention and design

      And I'm pretty sure you're wrong. Sorry. You might choose to measure font rendering that way--fidelity at any cost, even if it means reducing text to illegible blobs--but I don't, and evidently Microsoft doesn't either. In fact, I'd wager that most people don't.

      The technical ins and outs of photo editing and display are all about fidelity; why would that not be the case with typeface rendering and display?

      Because in many (if not most) cases, the primary purpose of rendering text is to make that text readable to the person sitting in front of the screen, and the formatting of that text is a secondary concern. In such cases, making "click here" distinguishable from "dick here" is more important than preserving the font designer's artistic vision.

      So the question is, if Microsoft had bothered to put some effort into proper rendering, would there be any meaningful loss of legibility?

      Empirically, the answer is obviously "no". As even that article points out, the determining factor is familiarity.

      Again, this is only true if you ignore what happens at small sizes.

      Why the article pretends that Microsoft's decision was anything other than lack of interest in fine-tuning is rather curious. [...] Pixel grid rendering is simply easier to implement

      Nope, you've got it backwards: Microsoft's approach involves more fine-tuning. Apple's approach is easier to implement: just scale the outline to the appropriate size and fill it in.

      Again, font rendering is measured by fidelity to the creator's intent. If the typeface is illegible because of blurring, then it's a poor typeface.

      Nonsense. A font that looks fine when rendered in a 15-pixel-high line (on a 300 DPI printer) may look illegible when rendered unchanged in a 5-pixel-high line (on screen). That doesn't mean the typeface is poor, it just means it's too intricate for such a low resolution.

      But Microsoft's decision to abandon the design in favor of a simplistic snap-to-grid renderer does nothing to improve legibility.

      You seem to be confused about how that renderer works. It's far from "simplistic snap-to-grid": simply snapping the font's vertices to a pixel grid would produce garbage. What it actually does is apply the TrueType hints found in the font file.

      The OS X font renderer ignores nearly all the hints, which is why the outline it renders at small sizes looks the same as the one it renders at large sizes: the hints are placed there by the font creator to tell renderers how to distort the outline at small sizes.

      (Indeed, Microsoft's ClearType renderer pays less attention to the hints than their old one, because the greater resolution of subpixel rendering makes horizontal pixel-fitting less important.)

      I happen to be of the print publication era, and I cannot stand the state of Microsoft and Linux font rendering. I'm happy to concede those with a personal and subjective preference for that system, but the reality is that it is objectively inferior in every way.

      No, not in every way; only in the particular way you've chosen to focus on. Your personal, subjective preference is showing.

      --
      Visual IRC: Fast. Powerful. Free.
    8. Re:HA! by David+Jao · · Score: 3, Interesting

      Talk about changing the goalposts! This whole Slashdot story is about fidelity.

      Woah there. First of all, as a neutral party, I dislike both Apple and Microsoft (I use Linux), and I have no agenda here. However, I do think that your viewpoint (as a self-admitted print publisher) is highly biased and useless to the majority of slashdot readers. This slashdot story is about image editing, but this thread is about on-screen font rendering. The two topics are different, and they need different goalposts.

      The technical ins and outs of photo editing and display are all about fidelity; why would that not be the case with typeface rendering and display?

      Viewing a photo is very very different from reading text. In fact, I find it completely preposterous that anyone would regard the two things as having anything in common.

      When I am reading text, I care about text fidelity, not image fidelity. I want to know what the letters and words are. I want to be able to read and re-read the text with minimal eyestrain. Unless you work in advertising or marketing (two industries which I loathe), the purpose of displaying or printing text is to accurately convey which letter is which and which word is which. Anything else (such as font accuracy) is only a means to this end. Anyone (such as you) who thinks font accuracy is worthy as an end in itself is clearly living in a different world from someone (such as me) who reads scientific papers (the vast majority of them on-screen, simply because carrying around 1GB worth of printed papers is impossible) and writes code for a living.

      I'm no great lover of Apple products, but as someone in print and publishing, this is one thing Apple does right and everyone else refuses to.

      There is a huge difference between printed text and text on a computer screen. The physical differences between the two are so vast, they can never be made to display exactly the same. I understand that, for someone like you who works in the publishing industry, it is important for computer screens to maintain fidelity to printed paper, since the printed paper is your end result. However, just because your profession depends crucially on font fidelity, does not mean that the same holds for other people.

      You need to understand that text on a computer screen is not always intended for publication on a printed page. Computer programming, in particular, involves writing large amounts of textual code, code which is almost never printed. Many slashdot readers are computer programmers, and couldn't give a flying f*ck about printing out their source code on paper. In such a situation, it is counterproductive to insist on image-level fidelity between text displayed on a computer monitor and text printed on a paper page. In fact, the optimal display strategy for computer programmers is almost completely the opposite of what you are saying, namely: render the font on the computer monitor so that it is as readable as possible on a computer screen, with absolutely zero regard for fidelity to printed output.

      Scenes intentionally filmed with judder that people go to great lengths to smooth out; proper calibration that is blown away by dynamic settings; sound mix and dynamic range that is hopelessly trampled by bass-loading equalizer fiends; photos being displayed in some other color space are all the same issue.

      Ironically, text rendering is the one issue that is different from all of the above. Text is a discrete medium: a letter is either an a, b, or c, or so on. Photos, sound, and video are analog media, perceived along a continuum by the human brain. Text fidelity means only one thing: being able to tell letters apart.

      If you were to print out Microsoft's rendered fonts in a novel, people would demand a reprint by the publisher. The objective reference is the superior reference.

    9. Re:HA! by Mr2001 · · Score: 2, Informative

      By now it's clear that you have no interest or understanding of any application of digital text other than what you've encountered in your own limited experience, and that you lack the technical knowledge to evaluate or discuss the workings of any font rendering algorithm.

      Between your ignorance, your accusations, your nonsensical demands (don't use a bitmap image to demonstrate the renderer's output), and your elitist insistence that you are the sole arbiter of what a font renderer is supposed to aim for as well as how a person is supposed to edit documents (always zooming in rather than reading text at small sizes; choosing a print font based on what looks good on screen, rather than using software that makes their preferred print font legible on screen), I see no reason to continue this discussion. Have a nice day.

      --
      Visual IRC: Fast. Powerful. Free.
  6. I look better in person. by ipquickly · · Score: 5, Funny

    I've been telling people for years that I look better in person.
    I told them that there's something wrong with pictures of me.

    HA!

    Now I know.

    It's the Scaling Algorithm BUG!

    1. Re:I look better in person. by grcumb · · Score: 2, Funny

      It's the Scaling Algorithm BUG!

      Man you gotta come up with a better line than that. Even 'I just went swimming', or 'It's cold in here' is more convincing than that!

      In any case, your girlfriend will still be disappointed....

      ... If you ever get one.

      --
      Crumb's Corollary: Never bring a knife to a bun fight.
  7. Oh dear. Linear color space again, 11 years later? by Animaether · · Score: 4, Insightful

    Come on, this isn't news...

    Helmut Dersch (of Panorama Tools fame) certainly posted about this before;
    http://www.all-in-one.ee/~dersch/gamma/gamma.html - Interpolation and Gamma Correction

    There's no factual error in the scaling algorithm, as the /. headline would like you to believe - it's a color space (linearity) issue; you have to do your calculations in linear space which means a typical photo off of a camera/scanner gets the inverse of an sRGB curve applied (a gamma of 0.454545 is 'close enough' if you can't do the proper color bits). Then scale. Then re-apply the curve.

    And no - for real life imagery, nobody really cares - the JPEGs out of the cameras and subsequent re-compression to JPEG after scaling will have 'destroyed' far more data than the linearity issue.

    They're nice example images in the story, but they should be called 'academic'.

  8. Re:What about Irfanview and Picasa? by cytoman · · Score: 3, Informative

    Gray rectangles in Picasa 3 and in Irfanview 4.25 :-(

  9. Re:Author expands scaling defination by Anonymous Coward · · Score: 5, Funny

    I am sure the Chinese government prefers the current implementation.

  10. Gamma and Computer Vision by drewm1980 · · Score: 3, Interesting

    Gamma is often poorly understood even by people doing scientific and engineering work using images.

    Does your algorithm depend (explicitly or implicitly) on the light intensity -> pixel data mapping?

    If NO: You're probably wrong. Go read about gamma. Just because the picture looks right to you, doesn't mean it looks right to your code.

    If YES:

    Do you have the luxury of taking the pictures yourself?

    If NO: You're stuffed. Pretty much all images on the internet and most public research databases have unknown/unreliable gamma curves.

    If YES:

    1. Spend a lot of time calibrating your camera yourself. This is only cheap if your time is worthless

    or

    2. Buy a machine vision camera. A $600 machine vision camera will have the specs of a $50 consumer camera, but at least you will know the gamma curve.

    or

    3. Ignore the gamma issue, cross your fingers, hope it's not hurting your performance, and publish your results knowing that you're in good company and nobody will call you out.

    1. Re:Gamma and Computer Vision by Anonymous Coward · · Score: 4, Interesting

      1. Spend a lot of time calibrating your camera yourself. This is only cheap if your time is worthless

      Typically this should be done during the initial set-up of any new camera that a photographer purchases. A Gretag Macbeth colour checker is cheap, the required shot to evaluate the performance of the sensor is quick and easy to set-up and the processing of this test image is fast with the right tools (like this script for photoshop). It should take under an hour to do it right and get it as part of the automatic stage of processing your RAW files (basically setting ACR/Lightroom's demosaicing stage), but the benefit is that every picture taken from then onwards does not need extra calibration. Thus your prints look like your shots, assuming the rest of your workflow is equally as calibrated.

      While your time is valuable, if you do not calibrate like this, you're wasting time further down the line for EACH image, and thus it's more expensive to not do it...

    2. Re:Gamma and Computer Vision by drewm1980 · · Score: 2, Insightful

      I was talking about scientific and engineering uses, which often depend on the gamma curve even if most authors ignore it.

      Most photographic software is oriented towards deliberately messing with the gamma curves arbitrarily to achieve aesthetic goals. Consumer cameras are even starting to do this onboard the camera, in, as far as I know, completely un-documented ways (indeed, they probably consider them trade secrets). See features like iContrast in canon cameras.

  11. Re:Oh dear. Linear color space again, 11 years lat by evanbd · · Score: 3, Informative

    The example images that make it really clear are academic examples. But the scaled photos are all enough of a change to be worth noticing and caring about if you're a serious amateur photographer (never mind professional). And they don't look particularly unusual to me (I haven't looked for odd trickery, but I assume he's being honest here).

  12. Gamma and sRGB by smasch · · Score: 4, Insightful

    The basic issue here has to do with gamma curves and the way they're being handled (they're not).

    Most image files on your computer (BMP, JPG, PNG, etc.) are stored in the sRGB color space. sRGB defines the use of a gamma curve, which is a nonlinear transformation applied to each of the components (R, G, and B). The issue here is that most scalers make the assumption that the components are linear, rather than try to process the gamma curve. While this does save processing time (undoing the gamma curve then redoing it), it does add some error, especially when the values being scaled are not near each other.

    So does this matter? Well, in some pathological cases where there are repeated sharp boundaries (such as alternating black-white lines or fine checkerboard patterns), this would make a difference. This is because the linear average of the pixels (what most image scalers use) yields a different result than if the gamma value was taken into account. For most images (both photographic and computer generated), this shouldn't be a big problem. Most samples are close in value to other nearby samples, so the error resulting from the gamma curve is very small. Sparse light-dark transitions also wouldn't be noticeable as there would only be an error right on the boundary. Only when you exercise this case over a large area does it become obvious.

    One final point: this gamma scaling effect would occur regardless of the actual scaling algorithm. Bilinear, bicubic, and sinc would all have the same issue. Nearest neighbor interpolation would be unaffected, but in these cases, the output would look far worse.

    1. Re:Gamma and sRGB by Zaphod+The+42nd · · Score: 3, Insightful

      I did RTFA, and yeah, this is pretty sorry. Apparently every image software developer out there cut corners, EVERY one, and it took us this long to notice.

      makes us wonder how much we're missing. Little mistakes here and there...

      --
      GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
  13. Re:Some look worse. by BoppreH · · Score: 2, Insightful

    That might be true, but it's no reason to turn this into an undocumented and unavoidable feature.

  14. Old news (and workaround) by JackHoffman · · Score: 5, Informative

    Ok, so he made a very informative page about it, but this is still a well known effect. It affects practically everything you can do in image editing. Blurs, etc. Most people neither notice nor care. It's rooted in the fact that most images come with undefined black and white points and a gamma chosen for artistic effect rather than physical accuracy. Thus correctly converting to linear gamma is hardly ever possible. You can still correct for monitor gamma to avoid some rarely seen inconsistencies and artifacts, but most people don't even notice, so why bother? However, Photoshop does have everything you need to avoid the effect completely, even in the ancient Photoshop 6.0.

    Here's how to properly resize in Photoshop:

    1. Convert mode to 16 bit (to avoid tone aliasing in the next step, no other influence on the calculations)
    2. Convert to profile, select "Custom RGB", set Gamma to 1.0 (this converts the internal image data to linear gamma, no visible change because the image is color managed and corrected back to monitor gamma on the fly)
    3. Image Size
    4. Convert to profile, select "Custom RGB", set Gamma to 2.2 (default)
    5. Convert mode to 8 bit

    Done. You can substitute your favorite image filter for the image resize. Unsharp mask works much better at gamma 1.0, for example. Of course you can use several filters before converting back to monitor gamma and 8 bit.

    1. Re:Old news (and workaround) by jcupitt65 · · Score: 3, Interesting

      Yes, it depends on the colourspace you use for the resize. If you resize in a non-linear colourspace, you will get (usually) tiny errors.

      I'm the author of one of the programs listed as defective (nip2). If you care about this issue, all you need to do is work in a linear space, such as XYZ (Click Colour / Colourspace / XYZ).

  15. Re:A great demo... by MortimerV · · Score: 4, Informative

    If you're looking for lcd test images, http://www.lagom.nl/lcd-test/ is probably better. It's got a whole bunch of images dedicated to various monitor problems, along with explanations.

  16. Re:Author expands scaling defination by scdeimos · · Score: 2, Informative

    You're absolutely correct, AC. The reported issue isn't about a linear/nonlinear gamma bug at all - it's an averaging side effect.

    The sample Dalai Lama image on TFA's page is intentionally constructed of interlaced lines of red and green data to thwart the averaging of source data used in common scaling algorithms. If you use the Gimp with the "None" scaling method, which will just pick-up every other row and column when scaling by 50%, (instead of trying to average 2x2 grids) you get a mostly-green image instead of the grey image advertised.

  17. Re:Oh dear. Linear color space again, 11 years lat by Animaether · · Score: 3, Interesting

    If you're a *serious* amateur photographer, then you should already know about this and not be using those apps / using them in the color modes (to use Photoshop parlance, as I guess most serious amateur photographers will have a copy (legit or otherwise of that)).

    I guess the argument would hinge on who is a serious amateur photographer and who is just a regular amateur photographer.

    As for the actual examples - sure, you can see the difference.. especially since they're in before/after -style swappable pages. If I presented you a random image off of a random image gallery online, though, would you be able to tell the difference?

    If I showed you an online photo album and pointed at an image's thumbnail, had you click the thumbnail, and open up the full size image.. would you notice that it was scaled to thumbnail incorrectly?

    "Nobody really cares" may have been too broad a statement - but those who really care, already know.. or reasonably should know.
    imho.

    Note that I'm not excusing the software programs from handling this better - certainly not Photoshop - but it's 1. not a new revelation and 2. certainly not a "scaling algorithm bug".

  18. Re:Oh dear. Linear color space again, 11 years lat by Skapare · · Score: 3, Informative

    It's basically an implementation issue. The algorithms may be fine as intended ... in linear space. The programmers that implemented them didn't understand linear vs. gamma, or didn't care, or had a fire breathing PHB on their back. Hence we get junk software.

    At least all MY image processing code always works in linear space. Bu merely converting 8-bit gamma to 8-bit linear is no good because that now introduces some serious quantizing artifacts (major banding effects happen). So I convert the 8-bit gammas to at least 30 or 31 bit integer if I need processing speed, or all the way to double precision floating point if I need as close to correct as possible. After processing, then I convert back to 8-bit gammas. Even then, you can't totally eliminate some banding effects that result from being in 8-bit. If you can get more bits from the raw images from your camera, that's the best to use. Apparently many JPEG compressors are also doing their DCT calculations in the non-unit gamma space instead of the linear space, too (which reduces the effectiveness of the compression somewhat, and may add more compression artifacts).

    --
    now we need to go OSS in diesel cars
  19. Old news by spitzak · · Score: 4, Interesting

    My software has been calculating in linear space for over a decade now (this is the Nuke Compositor currenlty produced by The Foundry but at the time it was used by Digital Domain for Titanic). You can see some pages I wrote on the effect here: http://mysite.verizon.net/~spitzak/conversion/composite.html. See here for the overall paper: http://mysite.verizon.net/~spitzak/conversion/index.html and a Siggraph paper on the conversion of such images here: http://mysite.verizon.net/~spitzak/conversion/sketches_0265.pdf, in fact a lot more work went into figuring out how to get such linear images to show on the screen on hardware of that era than on the obvious need to do the math in linear. Initial work on this was done for Apollo 13 as the problems with gamma were quite obvious when scaling images of small bright objects against the black of space.

    For typical photographs the effect is not very visible in scaling, as the gamma curve is very close to a straight line for two close points and thus the result is not very much different. Only widely separated points (ie very high contrast images with sharp edges) will show a visible difference. This probably means you are trying to scale line art, there are screenshots in the html pages showing the results of this. Far worse errors can be found in lighting calculations and in filtering operations such as blur. At the time even the most expensive professional 3D renderers were doing lighting completely wrong, but things have gotten better now that they can use floating point intermediate images.

    One big annoyance is that you better do the math in floating point. Even 16 bits is insufficient for linear light levels as the black points will be too far apart and visible (the space is wasted on many many more white levels than you ever would need). A logarithmic system is needed, and on modern hardware you might as well use IEEE floating point, or the ILM "half" standard for 16-bit floating point.

  20. Re:Nitpicking by caseih · · Score: 2, Insightful

    But the point of the article is that it is possible to do it correctly. As many posts have pointed out, the standard gamma for sRGB images where the gamma is not specified is 2.2. Not taking that into account is, in fact, an error. If the image data are not linear to begin with, then why are we applying algorithms to the image as if they were?

    Changing the image's gamma value during scaling is an error, plain and simple, especially when we know what the gamma of the image is to begin with!

    Programs like Picasa and other photography programs certainly should be taking this into account.

    Most professional photographers capture all their images to raw format. I think raw images are linear and are mapped to a gamma in post-production. So they probably will be less affected by this error. This may be why the pain/gain ratio for Adobe, for example, would be too large.

  21. Correct, yes. Expected, maybe. Desired, no. by Animaether · · Score: 3, Informative

    I think the author specifically isn't stating whether the scaling is correct or not - it is; the whole story doesn't relate to scaling at all, but rather color space and how -it- affects, among other, scaling. Yes, with filtering - scaling without filtering can hardly be called scaling at all as you're just discarding data - and for anything but multiples of 2 (4x, 2x, 0.5x, 0.25x, etc.) that'd have a whole 'nother set of problems.

    The author, I think, is suggesting, quite rightly so, that while...

    The grey square shown is the correct result

    ...it is not the expected (by laymen) nor desired (by just about anybody) result.

    The desired result for scaling down likely being that of the same visual image as when you simply stand further back.
    ( although at some point the resolution limit of a display and the image itself being presented on that display prevents that concept from being applied to "moving your eyeballs closer to the screen" for scaling up. )

  22. Re:Correct, yes. Expected, maybe. Desired, no. by icegreentea · · Score: 2, Insightful

    Well, as much as desired goes, this also affects how a lot of filters and effects work. For example, it causes most Gaussian blur implementations to 'flare' brights into darks more than they should. And that's been happening for so long, that that's now the expected/wanted behavior out of 'Gaussian Blurs'. If you changed that, you would have some confused/annoyed users.

  23. Wrong by sootman · · Score: 2, Insightful

    "There is an important error in most photography scaling algorithms."

    No, there isn't. If millions of professional users haven't been bothered by it over the course of two decades, it is CLEARLY not important.

    --
    Dear Slashdot: next time you want to mess with the site, add a rich-text editor for comments.
  24. Editing in RGB is wrong too by buzzn · · Score: 5, Informative

    Several people have spoken about "linear" RGB. That's nice and gets rid of some small level of distortion introduced by the non-linearity. However, it only starts there. For example, the eye sees R, G, and B differently. It is more sensitive to green than red, and to red more than blue, but it's not even that simple as the equations in your eye's processor are much more complicated. Many algorithms that treat the three "equally" are going to change the perceptual mixture. One can use other color spaces, such as HSV, Yuv, xyY, etc. with different advantages and disadvantages

    Sound makes a good analogy. When you play music through any given combination of source, amp and speakers, it sounds different. Sometimes we actually like a particular type of sonic "distortion". It's never exactly like the "original" live music, though.

    Likewise, any graphics manipulation is "distorting" the original. In fact, when I take a digital image and run it through Lightroom, do a range expansion/equalization, and do a bunch of tweaks to make the image look good, I'm making much larger changes than those little scaling problems listed in the article. The point is, do you think the result looks good?

    There's other important variables, such as what colors are next to other colors in the image, how long you look at the image, what else is around you, how tired you are, etc. There's no such thing as color fidelity, there's only approximations to it. Color is hard, and I mean, really hard. See Hunt, "The Reproduction of Colour", or any number of other fine texts to learn more.

    --
    Join the window installer's union, where prosperity is a brick throw away!
    1. Re:Editing in RGB is wrong too by eggnoglatte · · Score: 2, Informative

      Actually, different color spaces are OK, so long as they are just linear transformations from cone space. That is the case for (linear) RGB, (linear) HSV, XYZ, and a few others. As long as the transformation is linear (i.e. just a matrix times the color vector to give you a color vector in the cone space), you can apply any linear operation (such as scaling, blurring, and other weighted sums), and the order of transformation is exchangeable.

      For example, say LMS = M * RGB and you want to average two pixels. Then you have

      RGB_AVG = M^-1 * (1/2 * (M*RGB1 + M* RGB2)) = M^-1*M * 1/2 *(RGB1 + RGB2) = 1/2 (RGB1 + RGB2)

  25. Re:Nitpicking by im_thatoneguy · · Score: 2, Interesting

    It's not at all complicated. Many applications do properly handle it. Nuke, Shake and other compositing apps have no problem.

    Pixel^(GAMMA) -> Scale -> Pixel^(1/GAMMA) I wouldn't call that a terribly complicated process.

    Or even better. On open convert it to linear. Then on save convert it back. Maybe then Photoshop and company would actually handle alpha channels correctly *grumble* *grumble*...

  26. Re:Oh dear. Linear color space again, 11 years lat by evanbd · · Score: 2, Insightful

    Note that I'm not excusing the software programs from handling this better - certainly not Photoshop - but it's 1. not a new revelation and 2. certainly not a "scaling algorithm bug".

    In what sense is it not a scaling algorithm bug? The images look different after scaling than before, when interpreted in accordance with the appropriate specs. It seems to me that the specification for the scale function is something like "returns an image that is as visually similar as possible to the original, but reduced in size by the specified amount." It might be known, and it might be better described as using the wrong algorithm than an algorithm bug, but it's definitely a bug in the program.

    The rest of the post I basically agree with: the differences are minor except in weird test images. However, if I want to adjust the brightness, I'll do that. If I edit the photo at full res and then save at lower res for use on the web, I don't want the result to look different. I wouldn't be able to tell the difference if not in swappable comparisons, but one might still look better.

  27. Re:Author expands scaling defination by eelke_klein · · Score: 3, Informative

    Actually a good scaling algorithm should perform a lowpass filter when downscaling. This is similar to downsampling of digital audio where you do need to filter out frequencies above half the sampling rate. Leafing these higher frequencies in would cause noise because they can not be faithfully represented in a lower resolution file.

  28. Re:And this is still why, even in 2010. by profplump · · Score: 3, Funny

    The 270-year-old professional portrait artist tells me there is just a difference and photography hasn't made it up yet. He isn't giving up his canvas and I can't really blame him. I guess this isn't the film's fault and it shouldn't affect anything if the subject can be made to hold motionless for several minutes in a brightly-lit setting, but it makes you question if human-driven devices and systems should be abandoned at the current rates.

  29. Tux Paint has the code by r00t · · Score: 2, Informative

    The "magic" tools are done right. Scaling (for stamps) needs fixing.

    It's GPL. Grab the code if you want it: rgblinear.c and rgblinear.h have what you need.

    (and yes, the difference is very noticable for special-effect paint tools)

  30. bugs filed by r00t · · Score: 2, Funny

    Check the Gimp bug database. It has complaints going back many many years. Trouble is, a bug report is easy to ignore and/or misunderstand.

    Getting this fixed requires sitting down with all the core developers and using small words until it sinks into their thick skulls.

  31. This is not really a bug... by Anonymous Coward · · Score: 2, Interesting

    Eric Brasseur, in his otherwise excellent web page on the subject writes:

    Technically speaking, the problem is that "the computations are performed as if the scale
    of brightnesses was linear while in fact it is an exponential scale." In mathematical terms:
    "a gamma of 1.0 is assumed while it is 2.2." Lots of filters, plug-ins and scripts probably
    make the same error."

    That is sort of right in a sense, but the assumption that it is a problem with the scaling algorithm and worse, that it should be fixed in the algorithm are both wrong and a dangerous way to start thinking about this situation. In fact, this isn't really a bug anymore than the misuse of any tool is a bug. What is really needed is more knowledge and expertise on how to create and utilize a color managed imaging workflow.

    Almost all image processing algorithms contain simple addition somewhere and for simple addition to wok as you might expect, the image encoding function must be linear. (Adding logarithms for instance actually results in a multiplication operation. That is how slide rules work. What's a slide rule? Hmmm...) Scaling involves filtering and nearly all filtering algorithms involve addition, but so does a blur, over, blend, key, mask, matte, color correction, dithering and quite a few others. This problem isn't limited to scaling operations and it isn't a actually a bug at all, but rather an education and understanding issue.

    The right thing to do is to linearize your images prior to doing any kind of manipulation and keep them linear throughout the whole image manipulation process, only transforming them to something else for final delivery (or approval if that is an issue). By linear, I mean that the relationship between the luminance encoding and light is linear. You see, it isn't the image or the file that is linear or non-linear, it is that transfer function between code values and light. When I say linear, I mean that for a function f, f(a) + f(b) = f(a+b) and a*f(b) = f(a*b). Anything else is non-linear.

    The problem with working with linear images is that unless you are careful and know what you are doing, your monitor being a non-linear viewing device, won't display the images correctly, so if you linearize your images, they won't look "right" on the monitor, although they will be correct mathematically. The solution to that is to employ LUT in the viewer such that linear data is displayed correctly. Photoshop can do this and has been able to do it for years. The fact that people don't understand how to use that feature and why doesn't mean that there is a bug in the scaling algorithm.

    By the way, high end 2D image manipulation tools like Shake and Nuke to name two are used in the most demanding imaging application possible, motion picture visual effects. With regard to internal image processing, they presume that data is linear. They rely on the expert knowledge of the user to insure that the proper image encoding, that being linear to light is used.

    Lastly, I think thinking of this as a bug in scaling algorithms and trying to fix it by revising scaling algorithms rather than recognizing that it is really a problem with image data being encoded non-linearly is a completely wrong headed approach. It only addresses one use case, that being scaling and ignores all of the other problems with non-linearity. A better approach would be to educate people as to what is actually happening, why it is happening and then just teach them to use the tools they have.

    Just presuming that the input image has a 2.2 gamma and correcting for it in just the case of scaling but not in other 2D image manipulations only just serves to muddle the issue.

    Ultimately, you want is a display subsystem (display card and monitor) that has been profiled and then corrected to match as closely as possible some idealized target like sRGB or Rec. 709 just to name two. The easiest way to do that i

  32. Re:What about Irfanview and Picasa? by dotancohen · · Score: 2, Informative

    KDE's KolourPaint (MS Paint clone) gets it right! Yay KDE!

    --
    It is dangerous to be right when the government is wrong.
  33. Re:Author expands scaling defination by Anonymous Coward · · Score: 2, Interesting

    a low pass filter wouldn't work per se, as the color encoding used is non linear. most filters instead takes each channel of the picture producing an area average akin to a lowpass filter, but this is exactly where the problem lies as a: checkered black and white image (that is, every odd pixel on one row is white and the others black, reversed on the next row) is averaged to a contiguous half tone gray image, which is not the expected result because the gray scale is not linear in terms of luminance, so you'll need to have it averaged to a rgb(180,180,180) instead that to a rgb(128,128,128)

    *180 is not the actual value

  34. Re:It's already been discussed on Slashdot by orasio · · Score: 3, Insightful

    They summary already names a fix for Gimp (GEGL), but the posters only seem interested in whining instead of RTFS. Sigh.

  35. Re:What about Irfanview and Picasa? by AngryNick · · Score: 2, Funny

    Well, I RTFA and I completely understand why this is happening...the so called "sample photo" is covered with annoying little gray lines. No wonder the picture looks bad when you scale it. The dude needs a new camera.

  36. I thought it was just me by Xabraxas · · Score: 2, Interesting

    I noticed this bug the other day but I thought perhaps I made a mistake somewhere. I am creating a Drupal site for photos and it has a dark background. I was just testing out the image upload and I used an unscaled image. Later I scaled the same image down to save space and re-uploaded the image. The brightness was noticeably different. It's actually very hard to tell in a lot of cases, especially with a brighter background. A dark background really makes the bug apparent.

    --
    Time makes more converts than reason
  37. Re:The camera post-processes the sensor data by drewm1980 · · Score: 2, Insightful

    "the assumption one makes is that these integer values are not photons ^( 1/gamma) but simple photon counts (scaled to the 0-255 range)."

    That is a very reasonable assumption to make, and one that most people who don't know anything about gamma make. Unfortunately, it's flat out false. Both MATLAB and PIL return the gamma compressed data, which, unless you used a linear machine vision camera (and you should if you're serious about this stuff), which of course had no gamma compression to begin with. If you need proof, load and save an image. The image data will be bit for bit identical to the original, indicating that no conversions were performed. (note that the header might have slightly different metadata, and JPEG re-compression is usually always lossy)

    Gamma is so rarely handled properly, even by scientists and engineers, that OpenCV (the most popular library for computer vision) does not even contain a function for doing gamma (de)compression.