Bug or feature? That is the question!
Comments: 0 - Date: February 24th, 2010 - Categories: Bug, Image processing, Software Testing

A couple of hours ago, while “slashdotting” as usual, I read what I found a fascinating example of a debate between two groups of people about whether a particular behavior of some image scaling algorithms used by most popular image viewing and editing tools (GIMP, Photoshop, Firefox, …) is a bug or not. The story of this image scaling “bug” was slashdotted. In fact, the main article gives you a nice example of the phenomenon, but if you read the comments on slashdot you might understand the problem easier, because the main article is too verbose and somewhat complicated.
My example!
Before I explain the issue, I’ll give my own example that I just created with a script I wrote and a couple of my own images!
The picture on the side (—>) is mine!
It contains a hidden message. I’m not sure how the picture would look on other monitors, but on my laptop monitor, which is LCD, I can’t see the message normally unless I look at the screen from a very extreme angle from up or down since it’s LCD. On a CRT monitors, looking from different angles doesn’t change anything. I expect to hear that some people can read the message easily from the first look. Anyway, the example become interesting if you try to scale the image down 50%. This can be done easily with Firefox by pressing Ctrl+(-) (Control and minus) 4 times, or by holding control and scrolling up with the mouse. You can also try to open the image with your favorite image viewing or editing program and scale it down by 50%. I’d like to know your results using different programs.
So what happens?
Briefly, the issue comes from the fact that the human eye, combined with a specific monitor, doesn’t have a “linear” sensitivity for different scales of gray (or colors, generally speaking). Or, from another perspective, the way colors (or luminosity level) represented in digital computers is linear /or/ doesn’t match the non-linearity of the eye+monitor.
For example, black is usually represented as number 0, while white is 255. If we have an image with pixels alternating between black(0) and white(255), and we want to scale the image down to half size, most scaling algorithm (linear, cubic, except for nearest neighbor) will give you an image with pixel values of 127, a scale of gray that is supposed to be mid-point between black and white. However, if you look at the original image with your eye, it would appear lighter than the 127-grey image. In fact, it would look more like 186-gray level (depending on monitor).
How I created the image?
Briefly speaking, the example images you’ve seen, the one here and the ones in the original article, had an average value of pixels of 127, but each two adjacent pixels had a difference in value proportional with the pixel values of the original picture. Therefore what was a white color in the original picture, was presented as black(0) and white(255) pixels, which the eye will perceive as light-gray(186). Whereas what was black in the original picture, was represented by two grey(127) pixels, which the eye will perceive as (darker) gray(127).
Isn’t that a bug?
Yes and no!
If you think this is a problem that will reduce the value of the image editing program your using, then it’s a bug. If you think it doesn’t change anything for you, then it’s not a bug, at least not for you. A question whether something is a bug or not is not always obvious, in fact it’s a hard to decide more often than what most people think. Prof. Cem Kaner, in his Black Box Testing course / Bug Advocacy, has nice examples about the differences between bugs and features, and why it’s such subtle question to answer.
To me, this issue is not a bug. Real life pictures are different from the ones you’ve seen in this article and the original article. The examples you’ve seen are very specially crafted and produced by computers to expose the issue. In real pictures, the vast majority of adjacent pixels have very close values. So it won’t make any different if gamma correction was considered, That is, whether the average of (150 and 154) is 152 or 152.3, both cases will look exactly identical on the screen. Even when it happens that two adjacent pixels have a big difference in value, it’s still not a significant error in my humble opinion. There are a lot of sources of image errors and distortions much more severe that make this little error look really negligible, for example does the monitor have a correct gamma factor in the first place? And what about JPEG compression errors, etc.