725 lines
26 KiB
Markdown
725 lines
26 KiB
Markdown
# 高光谱图像分类与分析工具包
|
||
|
||
[](https://www.python.org/)
|
||
[](LICENSE)
|
||
|
||
一个全面的高光谱图像处理、分类和光谱分析工具包,具有GUI就绪架构。
|
||
|
||
## 🌟 功能特性
|
||
|
||
### 🔬 光谱分析
|
||
- **光谱指数计算**: 计算各种植被、矿物和水体指数
|
||
- **自定义公式支持**: 定义和计算自定义光谱指数
|
||
- **多格式支持**: 处理CSV、ENVI(.hdr/.dat)和其他光谱数据格式
|
||
|
||
### 🤖 机器学习模型
|
||
- **传统模型**: 线性回归、岭回归、LASSO、弹性网络、贝叶斯岭回归
|
||
- **集成方法**: 随机森林、梯度提升、XGBoost、LightGBM、AdaBoost
|
||
- **神经网络**: MLP、LSTM、GRU(支持TensorFlow/PyTorch)
|
||
- **专业模型**: 支持向量回归、高斯过程、KNN
|
||
|
||
### 🔍 异常检测
|
||
- **统计方法**: 协方差估计异常检测、RX异常检测算法
|
||
- **机器学习方法**: 单类SVM异常检测、平方损失概率异常检测
|
||
- **实时检测**: 支持像素级和区域级异常识别
|
||
- **多阈值支持**: 可配置的异常判定阈值和置信度
|
||
|
||
### 🏷️ 分类分析
|
||
- **传统算法**: SVM、随机森林、KNN、逻辑回归、LDA/QDA
|
||
- **集成方法**: AdaBoost、XGBoost、LightGBM、CatBoost
|
||
- **深度学习**: 支持TensorFlow/PyTorch神经网络模型
|
||
- **高光谱专用**: 偏最小二乘判别分析(PLS-DA)
|
||
- **模型评估**: 完整的分类报告、混淆矩阵、精度召回率F1分数
|
||
|
||
### 📊 聚类分析
|
||
- **无监督聚类**: K-Means、层次聚类、DBSCAN、高斯混合模型
|
||
- **监督聚类**: 基于标记数据的引导聚类算法
|
||
- **距离度量**: 欧几里得距离、曼哈顿距离、余弦相似度等
|
||
- **聚类评估**: 轮廓系数、Calinski-Harabasz指数、Davies-Bouldin指数
|
||
|
||
### 🎨 颜色分析
|
||
- **光谱转换**: 高光谱数据转CIE XYZ三刺激值
|
||
- **颜色空间**: XYZ到RGB、LAB、LUV等颜色空间转换
|
||
- **色差计算**: CIE76、CIE94、CIEDE2000色差公式
|
||
- **标准光源**: D65、D50、A、F系列等标准照明体
|
||
- **观察者模型**: CIE 1931 2° 和 CIE 1964 10° 标准观察者
|
||
|
||
### 🎯 特征选择
|
||
- **过滤方法**: 相关系数、互信息、方差阈值、卡方检验
|
||
- **包装方法**: 递归特征消除(RFE)、前向选择、后向消除
|
||
- **嵌入方法**: LASSO、岭回归、决策树特征重要性
|
||
- **专业算法**: SPA(连续投影算法)、CARS、UVE、GA(遗传算法)、ReliefF
|
||
- **批量处理**: 支持多算法并行特征选择和结果对比
|
||
|
||
### 🖼️ 图像处理
|
||
- **空间滤波**: 均值、中值、高斯和双边滤波
|
||
- **形态学滤波**: 开运算、闭运算、腐蚀、膨胀、形态学梯度、顶帽变换、黑帽变换
|
||
- **多波段支持**: 处理单个波段或整个高光谱数据立方体
|
||
- **格式保持**: 保持原始数据类型和数值范围
|
||
|
||
### 🔧 数据预处理
|
||
- **标准化处理**: Z-score标准化、Min-Max归一化、鲁棒标准化
|
||
- **异常值处理**: 基于IQR的方法、孤立森林、局部异常因子
|
||
- **数据转换**: 对数变换、Box-Cox变换、指数变换
|
||
- **缺失值处理**: 均值填充、中位数填充、KNN填充、插值方法
|
||
- **可视化分析**: 数据分布图、相关性热力图、异常值检测图
|
||
|
||
### 🌿 PROSAIL模拟
|
||
- **叶片光学**: PROSPECT模型模拟叶片光谱反射特性
|
||
- **冠层结构**: SAIL模型模拟植被冠层结构影响
|
||
- **土壤反射**: 多种土壤类型的光谱反射模拟
|
||
- **几何参数**: 太阳天顶角、观测天顶角、相对方位角
|
||
- **生物物理参数**: 叶绿素含量、叶片结构参数、水分含量等
|
||
|
||
|
||
### 📊 降维分析
|
||
- **主成分分析 (PCA)**: 最大化方差的线性降维
|
||
- **独立成分分析 (ICA)**: 基于统计独立的信号分离
|
||
- **因子分析 (FA)**: 基于潜在因子的降维方法
|
||
- **线性判别分析 (LDA)**: 有监督的类别可分性最大化
|
||
- **流形学习**: MDS、Isomap、LLE、t-SNE 等非线性降维
|
||
- **自动推荐**: 根据数据类型和规模推荐最适合的方法
|
||
|
||
### 🎯 图像分割
|
||
- **阈值分割**: 固定阈值、直方图双峰法、迭代法、Otsu法、ISODATA
|
||
- **自适应分割**: 基于局部区域统计的自适应阈值
|
||
- **批量处理**: 支持多方法多波段的批量分割
|
||
- **参数调优**: 丰富的参数配置选项
|
||
|
||
### ⚡ 边缘检测
|
||
- **经典算子**: Sobel、Scharr、Laplacian 算子
|
||
- **高级方法**: Laplacian of Gaussian (LoG)、Canny 算子
|
||
- **参数可调**: 每个方法都有丰富的参数配置选项
|
||
- **预处理**: 支持高斯模糊预处理以减少噪声
|
||
- **多尺度**: 支持不同尺度参数的边缘检测
|
||
|
||
### 📐 形状特征分析
|
||
- **连通域分析**: 自动识别和标记二值图像中的连通区域
|
||
- **分水岭分割**: 可选的分水岭算法用于分离相邻物体
|
||
- **13种形状特征**: 面积、周长、圆形度、矩形度、长宽比、紧密度、偏心率等
|
||
- **Hu矩提取**: 具有平移、旋转和缩放不变性的形状描述符
|
||
- **轮廓分析**: 基于边缘坐标的形状特征计算
|
||
- **多格式支持**: 支持ENVI dat文件和shp矢量文件输入
|
||
- **CSV输出**: 结构化的特征数据输出,包含边缘坐标信息
|
||
|
||
|
||
## 📋 系统要求
|
||
|
||
### 系统配置
|
||
- Python 3.8 或更高版本
|
||
- 4GB+ RAM(推荐大型数据集使用8GB+)
|
||
- GPU 支持(可选,用于深度学习模型)
|
||
|
||
### 依赖包
|
||
|
||
核心依赖包(完整列表见 `requirements.txt`):
|
||
```
|
||
numpy>=1.21.0
|
||
pandas>=1.3.0
|
||
scikit-learn>=1.0.0
|
||
matplotlib>=3.5.0
|
||
xgboost>=1.5.0
|
||
lightgbm>=3.3.0
|
||
```
|
||
|
||
可选依赖包:
|
||
- `tensorflow` 或 `torch` 用于深度学习模型
|
||
- `spectral` 用于ENVI文件处理
|
||
- `opencv-python` 用于图像滤波
|
||
|
||
## 🚀 安装指南
|
||
|
||
### 1. 克隆仓库
|
||
```bash
|
||
git clone http://git.iris-rs.cn/zhanghuilai/HSI.git
|
||
cd HSI
|
||
```
|
||
|
||
### 2. 创建虚拟环境(推荐)
|
||
```bash
|
||
python -m venv hyperspectral_env
|
||
source hyperspectral_env/bin/activate # Windows: hyperspectral_env\Scripts\activate
|
||
```
|
||
|
||
### 3. 安装依赖包
|
||
```bash
|
||
pip install -r requirements.txt
|
||
```
|
||
|
||
### 4. 根据需要安装可选依赖包
|
||
```bash
|
||
# 深度学习支持
|
||
pip install tensorflow # 或 torch
|
||
|
||
# ENVI文件处理
|
||
pip install spectral
|
||
|
||
# 开发环境
|
||
pip install pytest jupyter
|
||
```
|
||
|
||
## 📖 使用方法
|
||
|
||
### 基础用法
|
||
|
||
```python
|
||
# 1. 降维分析
|
||
from Dimensionality_Reduction_method.dimensionality_reduction import HyperspectralDimReduction, DimensionalityReductionConfig
|
||
|
||
config = DimensionalityReductionConfig(
|
||
input_path="hyperspectral_data.hdr",
|
||
method='pca',
|
||
n_components=5,
|
||
output_dir='results'
|
||
)
|
||
reducer = HyperspectralDimReduction(config)
|
||
reducer.load_data()
|
||
reduced_data, band_names = reducer.apply_dim_reduction()
|
||
reducer.save_results(reduced_data, band_names, 'pca_result.dat', 'pca')
|
||
|
||
# 2. 图像分割
|
||
from segment_method.threshold_Segment import ThresholdSegmenter, ThresholdSegmentationConfig
|
||
|
||
seg_config = ThresholdSegmentationConfig(
|
||
input_path="hyperspectral_data.hdr",
|
||
band_index=50,
|
||
method='otsu',
|
||
output_dir='segmentation_results'
|
||
)
|
||
segmenter = ThresholdSegmenter(seg_config)
|
||
segmenter.load_data()
|
||
segmented_data, threshold = segmenter.apply_segmentation()
|
||
segmenter.save_results(segmented_data, threshold, 'otsu_result.dat', 'otsu')
|
||
|
||
# 3. 边缘检测
|
||
from edge_detect_method.edge_detect import EdgeDetector, EdgeDetectionConfig
|
||
|
||
edge_config = EdgeDetectionConfig(
|
||
input_path="hyperspectral_data.hdr",
|
||
band_index=30,
|
||
method='canny',
|
||
output_dir='edge_results'
|
||
)
|
||
detector = EdgeDetector(edge_config)
|
||
detector.load_data()
|
||
edge_data, info = detector.apply_edge_detection()
|
||
detector.save_results(edge_data, info, 'canny_result.dat', 'canny')
|
||
```
|
||
|
||
### 新功能使用示例
|
||
|
||
```python
|
||
# 降维分析 - 批量处理多种方法
|
||
from Dimensionality_Reduction_method.dimensionality_reduction import HyperspectralDimReduction, DimensionalityReductionConfig
|
||
|
||
config = DimensionalityReductionConfig(
|
||
input_path="data.hdr",
|
||
output_dir="dim_reduction_results"
|
||
)
|
||
reducer = HyperspectralDimReduction(config)
|
||
reducer.load_data()
|
||
|
||
# 批量应用多种降维方法
|
||
methods = ['pca', 'ica', 'fa', 'lda'] # 如果有标签
|
||
components = [5, 5, 5, 3]
|
||
results = reducer.batch_process(methods, components, "dim_reduction_results")
|
||
|
||
# 图像分割 - 参数调优
|
||
from segment_method.threshold_Segment import ThresholdSegmenter, ThresholdSegmentationConfig
|
||
|
||
seg_config = ThresholdSegmentationConfig(
|
||
input_path="data.hdr",
|
||
band_index=100,
|
||
method='otsu',
|
||
output_dir="segmentation_results"
|
||
)
|
||
segmenter = ThresholdSegmenter(seg_config)
|
||
segmenter.load_data()
|
||
|
||
# 批量应用多种分割方法
|
||
methods = ['otsu', 'isodata', 'adaptive', 'iterative']
|
||
bands = [100, 100, 100, 100]
|
||
results = segmenter.batch_process(methods, bands, "segmentation_results")
|
||
|
||
# 边缘检测 - 高级参数配置
|
||
from edge_detect_method.edge_detect import EdgeDetector, EdgeDetectionConfig
|
||
|
||
edge_config = EdgeDetectionConfig(
|
||
input_path="data.hdr",
|
||
band_index=50,
|
||
method='canny',
|
||
canny_min_threshold=50,
|
||
canny_max_threshold=150,
|
||
use_blur=True,
|
||
blur_sigma=1.5,
|
||
output_dir="edge_results"
|
||
)
|
||
detector = EdgeDetector(edge_config)
|
||
detector.load_data()
|
||
|
||
# 批量应用多种边缘检测方法
|
||
methods = ['sobel', 'scharr', 'laplacian', 'log', 'canny']
|
||
bands = [50, 50, 50, 50, 50]
|
||
results = detector.batch_process(methods, bands, "edge_results")
|
||
|
||
# 4. 形状特征分析 - 高级配置
|
||
from spatial_features_method.shape_feature import ShapeFeatureConfig, analyze_shape_features
|
||
|
||
shape_config = ShapeFeatureConfig()
|
||
shape_config.input_type = 'dat'
|
||
shape_config.dat_file_path = "segmented_image.dat"
|
||
shape_config.hdr_file_path = "segmented_image.hdr"
|
||
shape_config.band_index = 0
|
||
shape_config.connectivity = 8 # 8连通
|
||
shape_config.min_area = 100 # 过滤小区域
|
||
shape_config.use_watershed = True # 启用分水岭算法
|
||
shape_config.watershed_min_distance = 15 # 分水岭参数
|
||
shape_config.output_dir = "shape_analysis_results"
|
||
|
||
# 执行形状特征分析
|
||
features_df, labeled_image = analyze_shape_features(shape_config)
|
||
print(f"分析完成,发现 {len(features_df)} 个有效区域")
|
||
print("提取的特征包括:面积、周长、圆形度、Hu矩等")
|
||
```
|
||
|
||
### 命令行使用
|
||
|
||
```bash
|
||
# 光谱指数计算
|
||
python spectral_index_method/spectral_index.py input.hdr -i NDVI EVI -o results
|
||
|
||
# 批量计算所有光谱指数并生成PNG可视化
|
||
python spectral_index_method/spectral_index.py input.hdr -A -p -o batch_results
|
||
|
||
# 图像滤波
|
||
python fliter_method/Smooth_filter.py input.hdr -f mean -k 3 -b 20 -o filtered_output
|
||
|
||
# 降维分析(运行内置示例)
|
||
python Dimensionality_Reduction_method/dimensionality_reduction.py
|
||
|
||
# 图像分割(运行内置示例)
|
||
python segment_method/threshold_Segment.py
|
||
|
||
# 边缘检测(运行内置示例)
|
||
python edge_detect_method/edge_detect.py
|
||
|
||
# 异常检测
|
||
python Anomaly_method/Covariance.py input.hdr -c 0.1 -o anomaly_results
|
||
|
||
# 分类分析
|
||
python classfication_method/classfication.py input.hdr labels.csv -m svm -o classification_results
|
||
|
||
# 聚类分析
|
||
python cluster_method/cluster.py input.hdr -m kmeans -n 5 -o cluster_results
|
||
|
||
# 特征选择
|
||
python Feature_Selection_method/feture_select.py input.csv target_column -m spa -f 20 -o feature_results
|
||
|
||
# 颜色分析
|
||
python color_method/DeltaE.py lab_image.hdr standard_colors.csv -m CIEDE2000 -o color_results
|
||
|
||
# 数据预处理
|
||
python preprocessing_method/Preprocessing.py input.csv -m standard -o preprocessed_data
|
||
|
||
# GUI界面启动
|
||
python hyperspectral_gui_tkinter.py
|
||
```
|
||
|
||
### 高级配置
|
||
|
||
```python
|
||
# 自定义回归配置
|
||
config = RegressionConfig()
|
||
config.data.csv_path = "data.csv"
|
||
config.data.label_column = "chlorophyll"
|
||
config.data.spectrum_columns = "10:200" # 波长范围
|
||
config.models.tune_hyperparams = True
|
||
config.models.model_names = ['ridge', 'lasso', 'xgboost']
|
||
config.output.save_models = True
|
||
|
||
analyzer = RegressionAnalyzer(config)
|
||
results = analyzer.run_analysis_from_config()
|
||
```
|
||
|
||
### 快速开始 - 新功能
|
||
|
||
```python
|
||
# 1. 降维分析快速开始
|
||
from Dimensionality_Reduction_method.dimensionality_reduction import *
|
||
|
||
config = DimensionalityReductionConfig(
|
||
input_path="your_data.hdr",
|
||
method='pca',
|
||
n_components=3
|
||
)
|
||
processor = HyperspectralDimReduction(config)
|
||
processor.load_data()
|
||
reduced_data, bands = processor.apply_dim_reduction()
|
||
|
||
# 2. 图像分割快速开始
|
||
from segment_method.threshold_Segment import *
|
||
|
||
config = ThresholdSegmentationConfig(
|
||
input_path="your_data.hdr",
|
||
band_index=100,
|
||
method='otsu'
|
||
)
|
||
processor = ThresholdSegmenter(config)
|
||
processor.load_data()
|
||
segmented, threshold = processor.apply_segmentation()
|
||
|
||
# 3. 边缘检测快速开始
|
||
from edge_detect_method.edge_detect import *
|
||
|
||
config = EdgeDetectionConfig(
|
||
input_path="your_data.hdr",
|
||
band_index=50,
|
||
method='canny'
|
||
)
|
||
processor = EdgeDetector(config)
|
||
processor.load_data()
|
||
edges, info = processor.apply_edge_detection()
|
||
|
||
# 4. 形状特征分析快速开始
|
||
from spatial_features_method.shape_feature import *
|
||
|
||
config = ShapeFeatureConfig()
|
||
config.input_type = 'dat' # 或 'shp'
|
||
config.dat_file_path = "segmented_data.dat"
|
||
config.hdr_file_path = "segmented_data.hdr"
|
||
config.band_index = 0
|
||
config.use_watershed = False # 是否使用分水岭算法
|
||
config.min_area = 50 # 最小区域面积
|
||
|
||
features_df, labeled_image = analyze_shape_features(config)
|
||
|
||
# 5. 光谱指数批量计算和PNG可视化
|
||
from spectral_feature_method.spectral_index import *
|
||
|
||
# 配置批量计算所有指数并生成PNG
|
||
config = SpectralIndexConfig.create_quick_analysis(
|
||
data_file_path="hyperspectral_data.hdr",
|
||
indices_to_calculate=None # None = 所有指数
|
||
)
|
||
config.output.save_png_visualization = True
|
||
config.output.png_filename = "all_indices_visualization.png"
|
||
|
||
calculator = HyperspectralIndexCalculator(config)
|
||
results, fig = calculator.batch_calculate_and_visualize()
|
||
|
||
# 6. 异常检测快速开始
|
||
from Anomaly_method.Covariance import CovarianceAnomalyDetector, CovarianceAnomalyConfig
|
||
|
||
config = CovarianceAnomalyConfig(
|
||
input_path="hyperspectral_data.hdr",
|
||
contamination=0.1, # 异常样本比例
|
||
random_state=42
|
||
)
|
||
detector = CovarianceAnomalyDetector(config)
|
||
detector.load_data()
|
||
anomaly_scores, anomaly_labels = detector.detect_anomalies()
|
||
|
||
# 7. 分类分析快速开始
|
||
from classfication_method.classfication import HyperspectralClassifier, ClassificationConfig
|
||
|
||
config = ClassificationConfig(
|
||
input_path="hyperspectral_data.hdr",
|
||
label_path="labels.csv",
|
||
method='svm',
|
||
test_size=0.3
|
||
)
|
||
classifier = HyperspectralClassifier(config)
|
||
classifier.load_data()
|
||
results = classifier.train_and_evaluate()
|
||
|
||
# 8. 聚类分析快速开始
|
||
from cluster_method.cluster import HyperspectralClusterer, ClusteringConfig
|
||
|
||
config = ClusteringConfig(
|
||
input_path="hyperspectral_data.hdr",
|
||
method='kmeans',
|
||
n_clusters=5,
|
||
random_state=42
|
||
)
|
||
clusterer = HyperspectralClusterer(config)
|
||
clusterer.load_data()
|
||
labels, centers = clusterer.perform_clustering()
|
||
|
||
# 9. 特征选择快速开始
|
||
from Feature_Selection_method.feture_select import FeatureSelector, FeatureSelectionConfig
|
||
|
||
config = FeatureSelectionConfig(
|
||
data_path="hyperspectral_data.csv",
|
||
label_column="target",
|
||
method='spa',
|
||
n_features=20
|
||
)
|
||
selector = FeatureSelector(config)
|
||
selector.load_data()
|
||
selected_features, scores = selector.select_features()
|
||
|
||
# 10. 颜色分析快速开始
|
||
from color_method.DeltaE import ColorDifferenceCalculator, ColorDifferenceConfig
|
||
|
||
config = ColorDifferenceConfig(
|
||
lab_image_path="lab_image.hdr",
|
||
standard_colors_path="standard_colors.csv",
|
||
method='CIEDE2000'
|
||
)
|
||
calculator = ColorDifferenceCalculator(config)
|
||
color_differences = calculator.calculate_differences()
|
||
|
||
# 11. 预处理快速开始
|
||
from preprocessing_method.Preprocessing import DataPreprocessor, PreprocessingConfig
|
||
|
||
config = PreprocessingConfig(
|
||
input_path="raw_data.csv",
|
||
method='standard', # 标准化
|
||
handle_outliers=True,
|
||
outlier_method='iqr'
|
||
)
|
||
preprocessor = DataPreprocessor(config)
|
||
processed_data = preprocessor.process()
|
||
|
||
# 12. 形态学滤波快速开始
|
||
from fliter_method.morphological_fliter import MorphologicalFilter, MorphologicalFilterConfig
|
||
|
||
config = MorphologicalFilterConfig(
|
||
input_path="hyperspectral_data.hdr",
|
||
band_index=50,
|
||
operation='opening',
|
||
kernel_size=3
|
||
)
|
||
filter_obj = MorphologicalFilter(config)
|
||
filtered_data = filter_obj.apply_filter()
|
||
```
|
||
|
||
## 📁 项目结构
|
||
|
||
```
|
||
hyperspectral-toolkit/
|
||
├── Anomaly_method/
|
||
│ ├── Covariance.py # 协方差异常检测
|
||
│ ├── One_Class_SVM.py # 单类SVM异常检测
|
||
│ ├── RX.py # RX异常检测算法
|
||
│ └── squared_loss_probability.py # 平方损失概率异常检测
|
||
├── rgression_method/
|
||
│ ├── regression.py # 回归分析模块
|
||
│ └── regression_predict.py # 回归预测工具
|
||
├── classfication_method/
|
||
│ ├── classfication.py # 分类分析模块
|
||
│ └── bil2png.py # 图像格式转换
|
||
├── cluster_method/
|
||
│ └── cluster.py # 无监督聚类算法
|
||
├── supervize_cluster_method/
|
||
│ └── supervize_cluster.py # 监督聚类算法
|
||
├── color_method/
|
||
│ ├── DeltaE.py # 色差计算
|
||
│ ├── spectral2cie2.py # 光谱到CIE转换
|
||
│ └── XYZ2RGB.py # XYZ到RGB转换
|
||
├── Dimensionality_Reduction_method/
|
||
│ └── dimensionality_reduction.py # 降维分析
|
||
├── segment_method/
|
||
│ └── threshold_Segment.py # 阈值分割
|
||
├── edge_detect_method/
|
||
│ └── edge_detect.py # 边缘检测
|
||
├── fliter_method/
|
||
│ ├── Smooth_filter.py # 空间滤波模块
|
||
│ └── morphological_fliter.py # 形态学滤波
|
||
├── spectral_feature_method/
|
||
│ └── spectral_index.py # 光谱指数计算器
|
||
├── preprocessing_method/
|
||
│ ├── Preprocessing.py # 数据预处理
|
||
│ └── plot.py # 预处理可视化
|
||
├── spatial_features_method/
|
||
│ ├── shape_feature.py # 形状特征分析模块
|
||
│ ├── get_glcm.py # GLCM纹理特征计算
|
||
│ ├── glcm.py # GLCM纹理分析
|
||
│ └── plot.py # 特征可视化工具
|
||
├── Feature_Selection_method/
|
||
│ ├── feture_select.py # 特征选择主模块
|
||
│ ├── batch_feature_selection.py # 批量特征选择
|
||
│ ├── Cars.py # CARS算法
|
||
│ ├── GA.py # 遗传算法特征选择
|
||
│ ├── Lar.py # LAR算法
|
||
│ ├── random_fog.py # 随机蛙跳算法
|
||
│ ├── ReliefF.py # ReliefF算法
|
||
│ ├── sipls.py # SIPLS算法
|
||
│ ├── Spa.py # SPA算法
|
||
│ └── Uve.py # UVE算法
|
||
├── prosail_method/
|
||
│ ├── prosail_gui.py # PROSAIL GUI界面
|
||
│ ├── README.md # PROSAIL说明文档
|
||
│ ├── modules/ # PROSAIL核心模块
|
||
│ └── data/ # PROSAIL数据文件
|
||
├── data/
|
||
│ ├── class.csv # 分类数据
|
||
│ └── roi.xml # ROI标注数据
|
||
├── requirements.txt # 依赖包列表
|
||
├── README.md # 本文件
|
||
├── PROJECT_DOCUMENTATION.md # 完整技术文档
|
||
└── shuoming.py # 说明文件
|
||
```
|
||
|
||
## 🔧 配置系统
|
||
|
||
该工具包使用为GUI集成设计的分层配置系统:
|
||
|
||
### 数据配置
|
||
```python
|
||
@dataclass
|
||
class DataConfig:
|
||
csv_path: str = ""
|
||
label_column: Union[str, int] = ""
|
||
spectrum_columns: Optional[Union[str, List]] = None
|
||
test_size: float = 0.2
|
||
scale_method: str = 'standard'
|
||
```
|
||
|
||
### 模型配置
|
||
```python
|
||
@dataclass
|
||
class ModelConfig:
|
||
model_names: Optional[List[str]] = None # None = 所有模型
|
||
tune_hyperparams: bool = True
|
||
tuning_method: str = 'grid'
|
||
cv_folds: int = 5
|
||
```
|
||
|
||
### 训练配置
|
||
```python
|
||
@dataclass
|
||
class TrainingConfig:
|
||
epochs: int = 100
|
||
batch_size: int = 32
|
||
learning_rate: float = 0.001
|
||
```
|
||
|
||
## 🎨 可用算法
|
||
|
||
### 降维方法
|
||
- **线性方法**: PCA (主成分分析)、ICA (独立成分分析)、FA (因子分析)
|
||
- **监督方法**: LDA (线性判别分析)
|
||
- **非线性方法**: MDS (多维尺度分析)、Isomap (等度量映射)、LLE (局部线性嵌入)、t-SNE (t-分布随机邻域嵌入)
|
||
- **智能推荐**: 基于数据类型和规模的自动方法推荐
|
||
|
||
### 分割方法
|
||
- **阈值分割**: 固定阈值、直方图双峰法、迭代法阈值分割
|
||
- **自适应分割**: 基于局部统计的自适应阈值
|
||
- **自动方法**: Otsu (大津法)、ISODATA 阈值分割
|
||
- **参数调优**: 丰富的参数配置和批量处理支持
|
||
|
||
### 边缘检测方法
|
||
- **一阶导数**: Sobel 算子、Scharr 算子
|
||
- **二阶导数**: Laplacian 算子
|
||
- **复合方法**: Laplacian of Gaussian (LoG)、Canny 算子
|
||
- **参数控制**: 核大小、阈值、尺度参数等全面可调
|
||
|
||
### 形状特征分析
|
||
- **连通域分析**: 4/8连通的连通域标记和分析
|
||
- **分水岭分割**: 基于距离变换的分水岭算法用于物体分离
|
||
- **几何特征**: 面积、周长、质心坐标、边界框
|
||
- **形状描述符**: 圆形度、矩形度、长宽比、紧密度、偏心率
|
||
- **矩特征**: Hu不变矩(7个)、中心矩
|
||
- **拓扑特征**: 凸性、固体度、轮廓复杂度
|
||
|
||
### 回归模型
|
||
- **线性模型**: 线性回归、岭回归、LASSO、弹性网络、贝叶斯岭回归
|
||
- **集成模型**: 随机森林、梯度提升、AdaBoost
|
||
- **提升模型**: XGBoost、LightGBM
|
||
- **神经网络**: MLP、LSTM、GRU
|
||
- **专业模型**: SVR、高斯过程、KNN
|
||
|
||
### 光谱指数
|
||
- **植被指数**: NDVI、EVI、ARVI、SAVI 等
|
||
- **水体指数**: NDWI、MNDWI 等
|
||
- **矿物指数**: 各种矿物特定指数
|
||
- **自定义指数**: 用户定义的公式
|
||
|
||
### 异常检测算法
|
||
- **统计方法**: 协方差估计异常检测、RX异常检测算法
|
||
- **机器学习方法**: 单类SVM异常检测、平方损失概率异常检测
|
||
- **参数配置**: 污染度阈值、置信度水平、可视化选项
|
||
- **输出格式**: 异常分数、异常标签、二值化结果
|
||
|
||
### 分类算法
|
||
- **传统算法**: SVM、随机森林、KNN、逻辑回归、LDA/QDA
|
||
- **集成方法**: AdaBoost、XGBoost、LightGBM、CatBoost
|
||
- **深度学习**: TensorFlow/PyTorch神经网络支持
|
||
- **高光谱专用**: PLS-DA偏最小二乘判别分析
|
||
- **模型评估**: 完整的性能指标和混淆矩阵分析
|
||
|
||
### 聚类算法
|
||
- **划分方法**: K-Means、K-Medoids
|
||
- **层次方法**: 凝聚层次聚类、分裂层次聚类
|
||
- **密度方法**: DBSCAN、OPTICS、高斯混合模型
|
||
- **评估指标**: 轮廓系数、Calinski-Harabasz指数、Davies-Bouldin指数
|
||
- **可视化**: 聚类结果二维/三维可视化
|
||
|
||
### 特征选择算法
|
||
- **过滤方法**: 方差阈值、相关系数、互信息、卡方检验
|
||
- **包装方法**: RFE递归特征消除、前向选择、后向消除
|
||
- **嵌入方法**: LASSO、岭回归、随机森林特征重要性
|
||
- **专业算法**: SPA(连续投影算法)、CARS、UVE、GA(遗传算法)、ReliefF
|
||
- **评估框架**: 交叉验证稳定性、特征重要性排序
|
||
|
||
### 颜色处理算法
|
||
- **光谱转换**: 高光谱到XYZ三刺激值、XYZ到RGB转换
|
||
- **色差计算**: CIE76、CIE94、CIEDE2000色差公式
|
||
- **标准观察者**: CIE 1931 2°、CIE 1964 10° 标准观察者
|
||
- **标准光源**: D65、D50、A、F系列标准照明体
|
||
- **配对比较**: 任意颜色样本间的色差分析
|
||
|
||
### 预处理算法
|
||
- **标准化**: Z-score标准化、Min-Max归一化、鲁棒标准化
|
||
- **异常值处理**: IQR方法、孤立森林、局部异常因子
|
||
- **数据转换**: 对数变换、Box-Cox变换、指数变换
|
||
- **缺失值处理**: 均值/中位数/众数填充、KNN填充、插值方法
|
||
- **质量评估**: 数据分布分析、相关性热力图、异常值检测
|
||
|
||
## 🚀 新功能特性详情
|
||
|
||
### 📊 降维分析系统
|
||
- **智能推荐**: 根据数据类型(图像/CSV)、样本数量和特征维度自动推荐最适合的降维方法
|
||
- **8种降维算法**: 从经典的PCA到先进的t-SNE,覆盖线性到非线性方法
|
||
- **批量处理**: 支持一次运行多种降维方法进行对比分析
|
||
- **详细报告**: 自动生成包含方法适用性和推荐理由的分析报告
|
||
|
||
### 🎯 阈值分割系统
|
||
- **6种分割方法**: 覆盖从简单固定阈值到高级Otsu和ISODATA方法
|
||
- **参数开放性**: 每个方法都有丰富的参数配置选项
|
||
- **批量对比**: 支持多方法多波段的批量分割处理
|
||
- **自动阈值**: 智能阈值选择和手动调优选项
|
||
|
||
### ⚡ 边缘检测系统
|
||
- **5种检测算法**: 从基础的Sobel算子到先进的Canny算法
|
||
- **参数可调**: 每个方法都有全面的参数控制选项
|
||
- **预处理支持**: 可选的高斯模糊预处理以减少噪声影响
|
||
- **多尺度分析**: 支持不同尺度参数的边缘特征提取
|
||
|
||
### 📐 形状特征分析系统
|
||
- **智能连通域分析**: 支持4连通和8连通的连通域标记
|
||
- **分水岭物体分离**: 可选的分水岭算法自动分离粘连物体
|
||
- **13种形状特征**: 从基本几何特征到高级形状描述符的全面分析
|
||
- **Hu不变矩**: 7个具有平移、旋转、缩放不变性的形状特征
|
||
- **轮廓坐标保存**: 完整的边缘坐标信息保存,便于后续分析
|
||
- **多格式输入**: 支持ENVI二值图像和shp矢量文件的输入
|
||
|
||
### 🎨 高级特性
|
||
- **配置驱动**: 所有模块都使用统一的数据类配置系统
|
||
- **批量处理**: 支持多参数、多方法的批量对比分析
|
||
- **智能验证**: 全面的参数校验和错误处理
|
||
- **ENVI兼容**: 完整的ENVI格式输入输出支持
|
||
- **文档齐全**: 每个方法都有详细的使用说明和参数解释
|
||
|
||
## 📊 输出格式
|
||
|
||
- **ENVI格式**: 标准高光谱数据格式(.dat + .hdr),包含详细的处理信息和参数
|
||
- **CSV**: 包含统计信息和结果的表格数据
|
||
- **图像**: PNG格式的可视化结果和图表
|
||
- **模型**: Pickle格式的sklearn模型用于部署
|
||
- **配置**: JSON格式的参数配置保存和恢复
|
||
- **轮廓数据**: JSON格式的形状轮廓坐标信息(形状特征分析专用)
|
||
- **标记图像**: 带标签的分割结果图像(ENVI + PNG格式)
|
||
|