【极化 SAR 图像分类】H-Alpha 分类

💡希望这篇内容可以帮到来自未来的你。

样图

实现

部分缺省实现可参考:【极化 SAR 图像分类】H-Alpha 平面绘制_jaredyam的博客-CSDN博客

import matplotlib.pyplot as plt
import numpy as np


def h_alpha_classifier(h, alpha, return_classnames=False):
    assert isinstance(h, np.ndarray)
    assert isinstance(alpha, np.ndarray)
    assert h.shape == alpha.shape
    assert h.ndim == 2
    image_shape = h.shape

    zones = {
        "High Entropy Multiple Scattering": (0.9 <= h) & (55 <= alpha),
        "High Entropy Vegetation Scattering": (0.9 <= h) & (40 <= alpha) & (alpha < 55),
        # "High Entropy Surface Scattering (Not a Feasible Region)": (0.9 <= h) & (alpha < 40),
        "Medium Entropy Multiple Scattering": (0.5 <= h) & (h < 0.9) & (50 <= alpha),
        "Medium Entropy Vegetation Scattering": (0.5 <= h) & (h < 0.9) & (40 <= alpha) & (alpha < 50),
        "Medium Entropy Surface Scattering": (0.5 <= h) & (h < 0.9) & (alpha < 40),
        "Low Entropy Multiple Scattering": (h < 0.5) & (47.5 <= alpha),
        "Low Entropy Dipole Scattering": (h < 0.5) & (42.5 <= alpha) & (alpha < 47.5),
        "Low Entropy Surface Scattering": (h < 0.5) & (alpha < 42.5),
    }
    labelmap = -np.ones(image_shape, dtype=np.int8)
    for n_zone, bitmap in enumerate(zones.values()):
        labelmap[bitmap] = n_zone
    return labelmap if not return_classnames else (labelmap, list(zones.keys()))


if __name__ == "__main__":
    sf = SanFrancisco()
    T3 = sf.load_T3(with_filter=True)
    h, alpha = h_alpha_decomposition(T3)

    fig, (ax_plane, ax_segmap) = plt.subplots(1, 2, figsize=(10, 4))

    curve_style = {
        "color": "black",
        "linewidth": 1,
    }
    ax_plane.plot(*h_alpha_decomposition(np.array([T3_curve1(m) for m in np.linspace(0, 1, 100)])), **curve_style)
    ax_plane.plot(*h_alpha_decomposition(np.array([T3_curve2(m) for m in np.linspace(0, 1, 100)])), **curve_style)

    bounds = [
        ([0.0, 0.5], [42.5, 42.5]),
        ([0.0, 0.5], [47.5, 47.5]),
        ([0.5, 0.5], [0.0, 90.0]),
        ([0.5, 0.9], [40.0, 40.0]),
        ([0.5, 0.9], [50.0, 50.0]),
        ([0.9, 0.9], [0.0, 90.0]),
        ([0.9, 1.0], [40.0, 40.0]),
        ([0.9, 1.0], [55.0, 55.0]),
    ]
    for xs, ys in bounds:
        ax_plane.plot(xs, ys, "--", color="gray", linewidth=1)

    labelmap = h_alpha_classifier(h, alpha)
    cmap = [
        (0.8, 0.8, 0.8),
        (0.3, 0.5, 0.2),
        (0.7, 0.2, 0.4),
        (0.3, 0.7, 0.3),
        (1.0, 0.8, 0.2),
        (0.9, 0.5, 0.3),
        (0.9, 0.3, 0.2),
        (0.2, 0.3, 0.6),
    ]
    segmap = np.zeros((*h.shape, 3))
    for n_zone, color in enumerate(cmap):
        ax_plane.scatter(x=h[labelmap == n_zone], y=alpha[labelmap == n_zone], marker=".", s=0.1, color=color)
        segmap[labelmap == n_zone] = color

    ax_plane.set_xlim(0, 1)
    ax_plane.set_ylim(0, 90)
    ax_plane.set_xlabel("Entropy")
    ax_plane.set_ylabel("Alpha")
    ax_plane.tick_params(top="on", right="on", direction="in")

    ax_segmap.imshow(segmap)
    ax_segmap.axis("off")
    plt.show()


参引

  1. Jong-Sen Lee, M. R. Grunes, T. L. Ainsworth, Li-Jen Du, D. L. Schuler and S. R. Cloude, “Unsupervised classification using polarimetric decomposition and the complex Wishart classifier,” in IEEE Transactions on Geoscience and Remote Sensing, vol. 37, no. 5, pp. 2249-2258, Sept. 1999, doi: 10.1109/36.789621.
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值