Methanol gas synthetic images

In general endmembres extracted from a cube give usefull information but only some endmembers can be used at the classification step. In fact, many things can influence a HSI cube analysis. For this example we take a cube that is very unmixing friendly.

The following figure show the object, a small methanol burner. At room temperature the methanol gas exit the burner. The cube is acquired in the VLW range of infrared, between 867 to 1288 wavenumber (cm-1) (7.76 to 11.54 micrometer) and it have 165 bands. The instrument used to acquire the data come from the Telops compagny. IR spectra are characteristic for chemical compounds, and their intensities are proportional to the concentration. It is what we show here. Unmixing give a fine-grained overview of the concentration.

The first step consist to extract the endmembers. The algorithm used is NFINDR with the initial working set initialized with ATGP. One of the good thing with using ATGP to create the initial working set is that this made NFINDR deterministic. Running it again with the same parameters give the same endmembers set. It is helpfull when we compare different result sets obtained with different NFINDR parametrization.

In [1]:
# Small methanol burner.
import os
import os.path as osp
from IPython.core.display import Image
home = os.environ['HOME']
Image(filename=osp.join(home, 'dev/pysptools/doc/bur/bur_burner_visible.png'))

First, we load the cube.

In [2]:
# Run on Python 2.7 and 3.x

from __future__ import print_function

%matplotlib inline

import numpy as np
import pysptools.util as util
import pysptools.eea as eea
import pysptools.abundance_maps as amp

# Load the cube
data_path = os.environ['PYSPTOOLS_DATA']

sample = 'burner.hdr'

data_file = osp.join(data_path, sample)
data, header = util.load_ENVI_file(data_file)

# Telops cubes are flipped left-right
# Flipping them again restore the orientation
data = np.fliplr(data)
In [3]:
def get_endmembers(data, header):
    print('Endmembers extraction with NFINDR')
    nfindr = eea.NFINDR()
    U = nfindr.extract(data, 12, maxit=5, normalize=True, ATGP_init=True)
    nfindr.display(header, suffix='gas')
    # return an array of endmembers
    return U

def gen_abundance_maps(data, U):
    print('Abundance maps generation with NNLS')
    nnls = amp.NNLS()
    amaps =, U, normalize=True)
    nnls.display(colorMap='jet', columns=3, suffix='gas')
    # return a cube of abundance maps
    return amaps

def display_synthetic_gas_above(amap, colormap):
    print('Create and display a synthetic map for the methanol above')
    gas = (amap > 0.1) * amap
    synt = gas[:,:,4] + gas[:,:,5] + gas[:,:,9] + gas[:,:,10]
    display(synt, colormap)

def display_synthetic_gas_around(amap, colormap):
    print('Create and display a synthetic map for the methanol around and methanol reflection')
    gas = (amap > 0.1) * amap
    synt = gas[:,:,6] + gas[:,:,7] + gas[:,:,8]
    display(synt, colormap)

def display_synthetic_burner(amap, colormap):
    print('Create and display a synthetic map for the burner')
    burner = (amap > 0.1) * amap
    synt = burner[:,:,2] + burner[:,:,3]
    display(synt, colormap)

def display(image, colormap):
    import matplotlib.pyplot as plt
    img = plt.imshow(image)

The next figures present the result set obtained by running NFINDR. For this case, twelve endmembers extracted was a good compromise. They give the information needed.

In [4]:
U = get_endmembers(data, header)
Endmembers extraction with NFINDR
<matplotlib.figure.Figure at 0x7f0439378690>

The second step consist to generate the abundance maps from the extracted endmembers. To present the result, the twelve abundance maps are grouped by related field: the burner, the gas escaping the burner by the side, the gas escaping the burner by the top and the backgournd. The standard interpretation for the gas leaving by the side is a reflection of the gas leaving by the top on the burner's metallic casing. Is it a reflection or the unmixing can detect the gas leaving by the side, I don't no. But, a combination of both is a good hypothesis.

In [5]:
amaps = gen_abundance_maps(data, U)
Abundance maps generation with NNLS
<matplotlib.figure.Figure at 0x7f04390fdf10>

Finally, the synthetic images are generated by first applying a threshold and after adding the related abundance maps. Next figures present the results: the burner synthetic image, the gas leaving by the side and the gas leaving by the top.

In [6]:
# best color maps: hot and spectral
display_synthetic_gas_above(amaps, 'spectral')
display_synthetic_gas_around(amaps, 'hot')
display_synthetic_burner(amaps, 'hot')
Create and display a synthetic map for the methanol above
Create and display a synthetic map for the methanol around and methanol reflection
Create and display a synthetic map for the burner
<matplotlib.figure.Figure at 0x7f0439043690>