Download: latest (1.8.0)

pymagery — python imagery


1.5.0 documentation / sepia plugin

Sepia, strictly speaking, is a color of brown. (It is generally agreed to be at an RGB value of #704214.) Sepia also refers to a coloring a grayscale image with a sepia tone. The sepia-toned image is generally associated with an "old-time feel" of the 19th century. Numerous digital cameras support direct conversion to sepia in situ.

The plugin prototype is:

def sepia()

Sepia conversion is a weighted mapping of colors and, thus, has no real correct answer. The weights used in this plugin are taken from http://msdn.microsoft.com/msdnmag/issues/05/01/NETMatters/.

R' = (R*0.393 + G*0.769 + B*0.189) / 1.351 G' = (R*0.349 + G*0.686 + B*0.168) / 1.351 B' = (R*0.272 + G*0.534 + B*0.131) / 1.351

The only difference from this and the MSDN page is the 1.351 factor. Adding up the weights for R', G', and B' you get 1.351, 1.203, and 0.937, respectively. This clearly means that the mapped colors can exceed an 8-bit value if uncorrected. The 1.351 factor is the maximum of these three weight-sums and thus ensures that no matter the source data the resulting data will be bound to 8-bit values. The MSDN page does not address this at all (presumably there is some rule stated to handle this elsewhere).

As these weights can clearly indicate: there is no correct set of weights. Weight adjustment will slightly alter the mapped image but it may be no more "sepia" then that shown above.

The following example filters an RGB (a PPM file stores RGB) to sepia:

import pymagery i = pymagery.image('foo.ppm') i.sepia()

Change Log