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

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

样图

【极化 SAR 图像分类】H-Alpha 分类_第1张图片

实现

部分缺省实现可参考:【极化 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.

你可能感兴趣的:(极化SAR,python)