提问人:Lydia Tab 提问时间:10/4/2023 更新时间:10/4/2023 访问量:15
哨兵波段中的异常值检测
Outliers Detection in Sentinel Bands
问:
我有特定图块的 Sentinel 波段,我已经实现了云掩码。我现在应该创建一个 8 位的 RGB,但首先我必须减少图像中的异常值并减少高斯噪声。在减少异常值、归一化、重新缩放图像的过程中,我真的很困惑。我正在研究 Python,我的代码片段是:
# Use of cloudmasked images from previous exercise
denoised_imgs = {}
for band, values in cloudfree.items():
print(f'band max is {values.max()} and min is {values.min()}')
# Outlier Detection
mean_val = np.mean(values)
print(f'mean: {mean_val}')
std_val = np.std(values)
print(f'std: {std_val}')
z_scores = (values - mean_val) / std_val
thershold = 2
outlier_mask = np.abs(z_scores) > thershold
values[outlier_mask] = mean_val
rescaled = np.clip(values, 0, 255).astype(np.uint8)
min_val = np.min(values)
max_val = np.max(values)
normalized_data = ((values - min_val) / (max_val - min_val)) * 255
# Reduce Gaussian Blur
# img_blur = cv2.bilateralFilter(clipped_band, 9, 5, 5)
denoised_imgs[band] = normalized_data
# Stack RGB-denoised
rgb_denoised = np.dstack([denoised_imgs['B04'], denoised_imgs['B03'], denoised_imgs['B02']])
cropped_denoised = rgb_denoised[uly_pixel:lry_pixel, ulx_pixel:lrx_pixel]
cloudfree:字典,其中键是波段名称和值 image 数组 (values.dtype('UInt16'))
谢谢! L.
我正在尝试找出 python 中的异常值检测方法。 我正在使用这些库,我现在更愿意坚持使用它们。但我愿意接受其他图书馆对未来研究的建议。
# Import libraries
from pathlib import Path
from osgeo import gdal
import numpy as np
import cv2
import matplotlib.pyplot as plt
答: 暂无答案
评论