# Changeset 1897 for wwwTweet

Ignore:
Timestamp:
Nov 6, 2007, 2:33:26 AM (15 years ago)
Message:
• Updated result images from the new original Lenna images.
Location:
www/study
Files:
8 edited

Unmodified
Removed
• ## www/study/index.html

 r1894 the study.py Python program. Just install the python-gd package on your favourite operating system and run the script.

run the script. The original Lenna images were generated with the lenna.py program from the original colour 512×512 image.

1. Colour quantisation

But more importantly, if you are reading this document on a computer screen, you may have noticed that the above 50% pattern was closer to a 0.7 screen, you may have noticed that the above 50% pattern was closer to a 0.73 grayscale (left) than to the expected 0.5 value (right). If you are reading a printed copy, it might be a different matter.

class="inline" alt="introducing gamma" />

Éric Brasseur wrote a pretty comprehensive essay about why on a computer screen a 50% black and white pattern is equivalent to a gray value of 0.73 instead of 0.5. Conversely, it clearly means that a gray value of 0.5 should not be approached with a 50% black and white dither patterns.

• ## www/study/study.py

 r1894 # Tiny image class to make examples short and readable class Image(gd.image): def __init__(self, args): def __new__(args, truecolor = False): gd.gdMaxColors = 256 * 256 * 256 gd.image.__init__(self, args) if truecolor: return gd.image.__new__(args, True) else: return gd.image.__new__(args) def getGray(self, x, y): p = self.getPixel((x, y)) c = self.colorComponents(p)[0] / 255.0 return c def getRgb(self, x, y): p = self.getPixel((x, y)) rgb = self.colorComponents(p) return [rgb[0] / 255.0, rgb[1] / 255.0, rgb[2] / 255.0] def setGray(self, x, y, t): p = (int)(t * 255.999) c = self.colorResolve((p, p, p)) self.setPixel((x, y), c) def setRgb(self, x, y, r, g, b): r = (int)(r * 255.999) g = (int)(g * 255.999) b = (int)(b * 255.999) c = self.colorResolve((r, g, b)) self.setPixel((x, y), c) # Set our gamma value ga = 2.2 # Load the 256x256 grayscale Lenna image for y in range(80): for x in range(80): dest.setGray(x, y, math.pow(0.5, 1 / 2.2)) dest.setGray(x, y, math.pow(0.5, 1 / ga)) for x in range(80, 160): c = (x + y) & 1
Note: See TracChangeset for help on using the changeset viewer.