Extracting colour channel data in Python
Flatbed film scanners are used within radiation oncology medical physics departments for the scanning of radiosensitive film. Depending on the film in use, a physicist will want to extract colour channel data from the scan, which is frequently saved as a 48 bit TIFF image (with 16 bits per pixel per channel). For example, Gafchromic EBT3 is most sensitive in the red and green channels, and so these channels will be used in the determination of absorbed dose.
The popular Python Image Library (PIL) doesn’t work well with 48 bit TIFF images. Fortunately, there are a number of other options available that better support high colour depth. The
tifffile module, detailed here, for example, allows the simple reading of 48 bit data, and the extraction of specific colour channel data.
import tifffile as tiff image = tiff.imread('example.tif') red_channel = image[:, :, 0] green_channel = image[:, :, 1] blue_channel = image[:, :, 2]
tifffile module can be installed within an Anaconda installation using
conda, the Anaconda package manager, per the instructions found here:
conda install -c https://conda.anaconda.org/conda-forge tifffile