Uploaded image for project: 'Commons Imaging'
  1. Commons Imaging
  2. IMAGING-67

Improve speed of TIFF Index-Color Palette

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-alpha1
    • Format: TIFF
    • None

    Description

      TIFF supports an 8-bit-per-pixel, "indexed color" model in which the values in the source data give indices into a fixed palette of color settings. Unpacking data in this format requires two steps: (1) reading and unpacking the palette in the source file, (2) performing a look-up operation for each pixel to map the index value to a color. A similar approach was used in the original GIF specification and, checking wikipedia, it appears that it is also supported by PNG and BMP. TIFF files in this format are used extensively in mapping and Geographic Information System implementation.

      The current inplementation of the PhotometicInterpreterPalette for TIFF files has an inefficiency in that it performs the unpacking operation from step one each time a new pixel is read. Thus, if a file contains three million red pixels, the byte-manipulation for the color red is repeated three million times. It would be more efficient for the PhotometricInterpreterPalette class to perform the unpacking operation once, in its constructor. Since there are a maximum of 256 colors in an 8-bit palette, this approach would require moderate use of memory.

      In time tests this approach reduced the reading time for a large TIFF file by about 13 percent (for details on the timing procedures, see Tracker Item 58):

      Unmodified Code: 1204.9 ms.
      After change: 1049.7 ms.

      Attachments

        1. IndexColorPalette.tif
          67 kB
          Gary Lucas
        2. Tracker_Item_75_23_Apr_2012.patch
          2 kB
          Gary Lucas

        Activity

          People

            Unassigned Unassigned
            gwlucas Gary Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: