资源简介
基于Python的SAR变化检测算法,基于Python的SAR变化检测算法
代码片段和文件信息
import numpy as np
import scipy.stats
import matplotlib.pyplot as plt
import matplotlib.colors
from sar_data import *
class Gamma(object):
“““
Test statistic on equality of two Gamma parameters
Use for change detection between two single channel SAR images X and Y
n m are Equivalent Number of Looks (ENL)
“““
def __init__(self X Y n m shape):
self.X = X
self.Y = Y
self.n = n
self.m = m
self.shape = shape
self.Q = Y/X # Test statistic
def histogram(self percentile):
f = plt.figure(figsize=(8 4))
ax = f.add_subplot(111)
ax.hist(self.Q.flatten() bins=100 normed=True range=(05) color=‘#3F5D7D‘)
ax.spines[“top“].set_visible(False)
ax.spines[“right“].set_visible(False)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
ax.set_xlabel(‘Test statistic‘)
ax.set_ylabel(‘Frequency‘)
ax.set_ylim([0 1.1])
# Fisher‘s F overlay
F = scipy.stats.f(2*self.m 2*self.n)
x = np.linspace(0 5 500)
ax.plot(x F.pdf(x) color=‘black‘ linewidth=2)
# Select threshold from distrib quantile
t_inf t_sup = F.ppf(percentile/2) F.ppf(1 - percentile/2)
return f ax
def image_binary(self percentile):
F = scipy.stats.f(2*self.m 2*self.n)
t_inf t_sup = F.ppf(percentile/2) F.ppf(1 - percentile/2)
im = np.zeros_like(self.Q)
im[self.Q < t_inf] = 1
im[self.Q > t_sup] = 1
return im.reshape(self.shape)
def image_color2(self percentile):
“““
Change detection image with two colors indicating the change direction
Black - Gray - White
“““
F = scipy.stats.f(2*self.m 2*self.n)
t_inf t_sup = F.ppf(percentile/2) F.ppf(1 - percentile/2)
im = np.empty_like(self.Q)
im[:] = 0.5
im[self.Q < t_inf] = 0
im[self.Q > t_sup] = 1
return im.reshape(self.shape)
def image_color3(self percentile):
“““
Change detection image with blue/red indicating the change direction
“““
F = scipy.stats.f(2*self.m 2*self.n)
t_inf t_sup = F.ppf(percentile/2) F.ppf(1 - percentile/2)
im = np.empty((self.shape[0] self.shape[1] 3))
im[::] = np.array([0 0 0])
im[self.Q.reshape(self.shape) < t_inf] = np.array([170 63 57])
im[self.Q.reshape(self.shape) > t_sup] = np.array([35 100 103])
return im
def image_linear(self percentile):
pass
def multiENL_gamma(april may):
gamma = Gamma(april may 13 13 (1024 1024))
f = plt.figure(figsize=(8 4))
ax = f.add_subplot(111)
ax.hist(gamma.Q.flatten() bins=100 normed=True range=(03) color=‘#3F5D7D‘)
ax.spines[“top“].set_visible(False)
ax.spines[“right“].set_visible(False)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
ax.set_xlabe
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-05-26 13:16 SAR-change-detection-master\
文件 24 2015-05-26 13:16 SAR-change-detection-master\.gitignore
文件 1085 2015-05-26 13:16 SAR-change-detection-master\LICENSE.txt
文件 795 2015-05-26 13:16 SAR-change-detection-master\README.txt
文件 18811036 2015-05-26 13:16 SAR-change-detection-master\SAR_Change_Detection_Victor_Poughon.pdf
文件 8339 2015-05-26 13:16 SAR-change-detection-master\gamma.py
文件 5093 2015-05-26 13:16 SAR-change-detection-master\omnibus.py
文件 1516 2015-05-26 13:16 SAR-change-detection-master\plotting.py
文件 12182 2015-05-26 13:16 SAR-change-detection-master\rj.py
文件 6383 2015-05-26 13:16 SAR-change-detection-master\sar_data.py
文件 7227 2015-05-26 13:16 SAR-change-detection-master\wishart.py
- 上一篇:dbc文件转excel
- 下一篇:Python编程:从入门到实践全.pdf
评论
共有 条评论