Notes on proper handling of premultiplied ARGB

Benjamin Gilbert bgilbert at cs.cmu.edu
Mon Feb 9 02:49:50 EST 2015


Hi all,

One of the less-obvious requirements of the OpenSlide C API is the need 
for applications to properly handle premultiplied ARGB pixel data 
returned by openslide_read_region() and 
openslide_read_associated_image().  If this data is incorrectly treated 
as *un*premultiplied, background areas in Leica and MIRAX slides may be 
rendered as black pixels, and, more subtly, dark lines can appear on the 
borders between slide regions and background.  If unpremultiplied output 
is needed, the application must multiply each color channel by 255 and 
divide by alpha.  I've now documented this on the wiki:

     https://github.com/openslide/openslide/wiki/PremultipliedARGB

As I've learned the hard way (OpenSlide Python before Git master, VIPS 
before 7.42.2), unpremultiplication can seriously impact performance if 
implemented incautiously.  The wiki page includes an example 
implementation (not actually compile-tested) that shouldn't incur too 
much overhead.

--Benjamin Gilbert


More information about the openslide-users mailing list