Classifiers classes reference
This module supports HSI cube supervised classifiers. They are NormXCorr, SID and SAM.
For each classifier three differents plotting are availables.
See the file test_cls.py for an example.
NormXCorr
-
class classifiers.NormXCorr
Classify a HSI cube using the normalized cross correlation
algorithm and a spectral library.
-
classify(M, E, threshold=0.01)
Classify the HSI cube M with the spectral library E.
- Parameters:
- M: numpy array
- A HSI cube (m x n x p).
- E: numpy array
- A spectral library (N x p).
- threshold: float [default 0.1] or list
- If float, threshold is applied on all the signals.
- If a list, individual threshold is applied on each
signal, in this case the list must have the same
number of threshold values than the number of signals.
- Threshold have values between 0.0 and 1.0.
- Returns: numpy array
- A class map (m x n x 1).
-
display(colorMap='Accent', suffix=None)
Plot the class map on a IPython Notebook.
- Parameters:
- colorMap: string [default ‘Accent’]
- A color map element of
[‘Accent’, ‘Dark2’, ‘Paired’, ‘Pastel1’, ‘Pastel2’, ‘Set1’, ‘Set2’, ‘Set3’],
“Accent” is the default and it fall back on “Jet”.
- suffix: string [default None]
- Add a suffix to the title.
-
display_single_map(lib_idx, constrained=True, suffix=None)
Plot individual classified map on a IPython Notebook. One for each signal.
Note that each individual map is constrained by the others.
This function is usefull to see the individual map that compose
the final class map returned by the classify method. It help
to define the signals library. See the constrained parameter below.
- Parameters:
- lib_idx: int or string
- A number between 1 and the number of signals in the library.
- ‘all’, plot all the individual maps.
- constrained: boolean [default True]
- If constrained is True, print the individual maps as they compose the
final class map. Any potential intersection is removed in favor of
the lower value level for SAM and SID, or the nearest to 1 for NormXCorr. Use
this one to understand the final class map.
- If constrained is False, print the individual maps without intersection
removed, as they are generated. Use this one to have the real match.
- suffix: string [default None]
- Add a suffix to the title.
-
get_NormXCorr_map()
- Returns: numpy array
- The NormXCorr array (m x n x signals number).
-
get_single_map(lib_idx, constrained=True)
Get individual classified map. See plot_single_map for
a description.
- Parameters:
- path: string
- The path where to put the plot.
- lib_idx: int or string
- A number between 1 and the number of signals in the library.
- constrained: boolean [default True]
- See plot_single_map for a description.
- Returns: numpy array
- The individual map (m x n x 1) associated to the lib_idx endmember.
-
plot(path, colorMap='Accent', suffix=None)
Plot the class map.
- Parameters:
- path: string
- The path where to put the plot.
- colorMap: string [default ‘Accent’]
- A color map element of
[‘Accent’, ‘Dark2’, ‘Paired’, ‘Pastel1’, ‘Pastel2’, ‘Set1’, ‘Set2’, ‘Set3’],
“Accent” is the default and it fall back on “Jet”.
- suffix: string [default None]
- Add a suffix to the file name.
-
plot_histo(path, suffix=None)
Plot the histogram.
- Parameters:
- path: string
- The path where to put the plot.
- suffix: string [default None]
- Add a suffix to the file name.
-
plot_single_map(path, lib_idx, constrained=True, suffix=None)
Plot individual classified map. One for each signal.
Note that each individual map is constrained by the others.
This function is usefull to see the individual map that compose
the final class map returned by the classify method. It help
to define the signals library. See the constrained parameter below.
- Parameters:
- path: string
- The path where to put the plot.
- lib_idx: int or string
- A number between 1 and the number of signals in the library.
- ‘all’, plot all the individual maps.
- constrained: boolean [default True]
- If constrained is True, print the individual maps as they compose the
final class map. Any potential intersection is removed in favor of
the lower value level for SAM and SID, or the nearest to 1 for NormXCorr. Use
this one to understand the final class map.
- If constrained is False, print the individual maps without intersection
removed, as they are generated. Use this one to have the real match.
- suffix: string [default None]
- Add a suffix to the file name.
SAM
-
class classifiers.SAM
Classify a HSI cube using the spectral angle mapper algorithm
and a spectral library.
-
classify(M, E, threshold=0.1)
Classify the HSI cube M with the spectral library E.
- Parameters:
- M: numpy array
- A HSI cube (m x n x p).
- E: numpy array
- A spectral library (N x p).
- threshold: float [default 0.1] or list
- If float, threshold is applied on all the signals.
- If a list, individual threshold is applied on each
signal, in this case the list must have the same
number of threshold values than the number of signals.
- Threshold have values between 0.0 and 1.0.
- Returns: numpy array
- A class map (m x n x 1).
-
display(colorMap='Accent', suffix=None)
Plot the class map on a IPython Notebook.
- Parameters:
- colorMap: string [default ‘Accent’]
- A color map element of
[‘Accent’, ‘Dark2’, ‘Paired’, ‘Pastel1’, ‘Pastel2’, ‘Set1’, ‘Set2’, ‘Set3’],
“Accent” is the default and it fall back on “Jet”.
- suffix: string [default None]
- Add a suffix to the title.
-
display_single_map(lib_idx, constrained=True, suffix=None)
Plot individual classified map on a IPython Notebook. One for each signal.
Note that each individual map is constrained by the others.
This function is usefull to see the individual map that compose
the final class map returned by the classify method. It help
to define the signals library. See the constrained parameter below.
- Parameters:
- lib_idx: int or string
- A number between 1 and the number of signals in the library.
- ‘all’, plot all the individual maps.
- constrained: boolean [default True]
- If constrained is True, print the individual maps as they compose the
final class map. Any potential intersection is removed in favor of
the lower value level for SAM and SID, or the nearest to 1 for NormXCorr. Use
this one to understand the final class map.
- If constrained is False, print the individual maps without intersection
removed, as they are generated. Use this one to have the real match.
- suffix: string [default None]
- Add a suffix to the title.
-
get_angles_map()
- Returns: numpy array
- The angles array (m x n x signals number).
-
get_angles_stats()
- Returns: dic
- Angles stats.
-
get_single_map(lib_idx, constrained=True)
Get individual classified map. See plot_single_map for
a description.
- Parameters:
- path: string
- The path where to put the plot.
- lib_idx: int or string
- A number between 1 and the number of signals in the library.
- constrained: boolean [default True]
- See plot_single_map for a description.
- Returns: numpy array
- The individual map (m x n x 1) associated to the lib_idx endmember.
-
plot(path, colorMap='Accent', suffix=None)
Plot the class map.
- Parameters:
- path: string
- The path where to put the plot.
- colorMap: string [default ‘Accent’]
- A color map element of
[‘Accent’, ‘Dark2’, ‘Paired’, ‘Pastel1’, ‘Pastel2’, ‘Set1’, ‘Set2’, ‘Set3’],
“Accent” is the default and it fall back on “Jet”.
- suffix: string [default None]
- Add a suffix to the file name.
-
plot_histo(path, suffix=None)
Plot the histogram.
- Parameters:
- path: string
- The path where to put the plot.
- suffix: string [default None]
- Add a suffix to the file name.
-
plot_single_map(path, lib_idx, constrained=True, suffix=None)
Plot individual classified map. One for each signal.
Note that each individual map is constrained by the others.
This function is usefull to see the individual map that compose
the final class map returned by the classify method. It help
to define the signals library. See the constrained parameter below.
- Parameters:
- path: string
- The path where to put the plot.
- lib_idx: int or string
- A number between 1 and the number of signals in the library.
- ‘all’, plot all the individual maps.
- constrained: boolean [default True]
- If constrained is True, print the individual maps as they compose the
final class map. Any potential intersection is removed in favor of
the lower value level for SAM and SID, or the nearest to 1 for NormXCorr. Use
this one to understand the final class map.
- If constrained is False, print the individual maps without intersection
removed, as they are generated. Use this one to have the real match.
- suffix: string [default None]
- Add a suffix to the file name.
SID
-
class classifiers.SID
Classify a HSI cube using the spectral information divergence
algorithm and a spectral library.
-
classify(M, E, threshold=0.1)
Classify the HSI cube M with the spectral library E.
- Parameters:
- M: numpy array
- A HSI cube (m x n x p).
- E: numpy array
- A spectral library (N x p).
- threshold: float [default 0.1] or list
- If float, threshold is applied on all the signals.
- If a list, individual threshold is applied on each
signal, in this case the list must have the same
number of threshold values than the number of signals.
- Threshold have values between 0.0 and 1.0.
- Returns: numpy array
- A class map (m x n x 1).
-
display(colorMap='Accent', suffix=None)
Plot the class map on a IPython Notebook.
- Parameters:
- colorMap: string [default ‘Accent’]
- A color map element of
[‘Accent’, ‘Dark2’, ‘Paired’, ‘Pastel1’, ‘Pastel2’, ‘Set1’, ‘Set2’, ‘Set3’],
“Accent” is the default and it fall back on “Jet”.
- suffix: string [default None]
- Add a suffix to the title.
-
display_single_map(lib_idx, constrained=True, suffix=None)
Plot individual classified map on a IPython Notebook. One for each signal.
Note that each individual map is constrained by the others.
This function is usefull to see the individual map that compose
the final class map returned by the classify method. It help
to define the signals library. See the constrained parameter below.
- Parameters:
- lib_idx: int or string
- A number between 1 and the number of signals in the library.
- ‘all’, plot all the individual maps.
- constrained: boolean [default True]
- If constrained is True, print the individual maps as they compose the
final class map. Any potential intersection is removed in favor of
the lower value level for SAM and SID, or the nearest to 1 for NormXCorr. Use
this one to understand the final class map.
- If constrained is False, print the individual maps without intersection
removed, as they are generated. Use this one to have the real match.
- suffix: string [default None]
- Add a suffix to the title.
-
get_SID_map()
- Returns: numpy array
- The SID array (m x n x signals number).
-
get_single_map(lib_idx, constrained=True)
Get individual classified map. See plot_single_map for
a description.
- Parameters:
- path: string
- The path where to put the plot.
- lib_idx: int or string
- A number between 1 and the number of signals in the library.
- constrained: boolean [default True]
- See plot_single_map for a description.
- Returns: numpy array
- The individual map (m x n x 1) associated to the lib_idx endmember.
-
plot(path, colorMap='Accent', suffix=None)
Plot the class map.
- Parameters:
- path: string
- The path where to put the plot.
- colorMap: string [default ‘Accent’]
- A color map element of
[‘Accent’, ‘Dark2’, ‘Paired’, ‘Pastel1’, ‘Pastel2’, ‘Set1’, ‘Set2’, ‘Set3’],
“Accent” is the default and it fall back on “Jet”.
- suffix: string [default None]
- Add a suffix to the file name.
-
plot_histo(path, suffix=None)
Plot the histogram.
- Parameters:
- path: string
- The path where to put the plot.
- suffix: string [default None]
- Add a suffix to the file name.
-
plot_single_map(path, lib_idx, constrained=True, suffix=None)
Plot individual classified map. One for each signal.
Note that each individual map is constrained by the others.
This function is usefull to see the individual map that compose
the final class map returned by the classify method. It help
to define the signals library. See the constrained parameter below.
- Parameters:
- path: string
- The path where to put the plot.
- lib_idx: int or string
- A number between 1 and the number of signals in the library.
- ‘all’, plot all the individual maps.
- constrained: boolean [default True]
- If constrained is True, print the individual maps as they compose the
final class map. Any potential intersection is removed in favor of
the lower value level for SAM and SID, or the nearest to 1 for NormXCorr. Use
this one to understand the final class map.
- If constrained is False, print the individual maps without intersection
removed, as they are generated. Use this one to have the real match.
- suffix: string [default None]
- Add a suffix to the file name.