修改分割模块
This commit is contained in:
@ -9,6 +9,7 @@ import get_glcm
|
||||
import os
|
||||
import cv2
|
||||
import numpy as np
|
||||
import copy
|
||||
from plantcv.plantcv._helpers import _iterate_analysis, _cv2_findcontours, _object_composition, _grayscale_to_rgb, \
|
||||
_scale_size
|
||||
from plantcv.plantcv import outputs, within_frame
|
||||
@ -332,7 +333,7 @@ def process_images(full_bil_path, mask, outdir='None', debug="None"):
|
||||
spectral_array = pcv.readimage(filename=args.image, mode='envi')
|
||||
#过曝区域掩膜
|
||||
bath_100 = spectral_array.array_data[:, :, 100]
|
||||
bath_over = pcv.threshold.binary(gray_img=bath_100, threshold=11000, object_type='dark')
|
||||
bath_over = pcv.threshold.binary(gray_img=bath_100, threshold=11000, object_type='dark')#
|
||||
|
||||
# mask已经是16位标签掩膜,直接使用
|
||||
# 确保掩膜是正确的数据类型
|
||||
@ -367,8 +368,11 @@ def process_images(full_bil_path, mask, outdir='None', debug="None"):
|
||||
shape_img = size(img=binary_img, labeled_mask=labeled_mask, n_labels=num_valid)
|
||||
|
||||
# 分析光谱反射率
|
||||
# 应用过曝掩膜
|
||||
labeled_spectral_mask = mask * bath_over_binary
|
||||
# 应用过曝掩膜 ;如果采集的反射率大于1.1,则会被错误判断为过曝区域导致该样本的光谱没有被统计
|
||||
# labeled_spectral_mask = mask * bath_over_binary
|
||||
labeled_spectral_mask = mask
|
||||
|
||||
|
||||
|
||||
spectral_hist = pcv.analyze.spectral_reflectance(
|
||||
hsi=spectral_array,
|
||||
@ -377,13 +381,16 @@ def process_images(full_bil_path, mask, outdir='None', debug="None"):
|
||||
label=None
|
||||
)
|
||||
|
||||
observations = pcv.outputs.observations
|
||||
# 深拷贝观测结果,避免后续清空影响数据
|
||||
observations = copy.deepcopy(pcv.outputs.observations)
|
||||
# 立即清空全局缓存,防止跨文件/阶段累加
|
||||
pcv.outputs.clear()
|
||||
# 将结果转换为列表
|
||||
combined_data = process_plantcv_outputs(observations)
|
||||
|
||||
return combined_data
|
||||
|
||||
# # 示例:批量处理指定路径下的光谱图像和掩膜文件
|
||||
# # # 示例:批量处理指定路径下的光谱图像和掩膜文件
|
||||
# bil_path = r'D:\WQ\test\Traindata-05'
|
||||
# mask_path = r'D:\WQ\test\mask'
|
||||
# outdir = r"D:\WQ\test" # 输出文件夹路径
|
||||
|
||||
Reference in New Issue
Block a user