microproduct-l-sar/vegetationHeight-L-SAR/test.py

63 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import numpy as np
from tool.algorithm.image.ImageHandle import ImageHandler
from matplotlib import pyplot as plt
import matplotlib as mpl
from scipy import signal
import scipy
cmap = mpl.cm.jet_r
def show_filt():
mas = r"D:\micro\LWork\VegetationHeight\Temporary\preprocessed\master_s2\s11.bin"
aux = r"D:\micro\LWork\VegetationHeight\Temporary\preprocessed\slave_s2\s11.bin"
out_file = r'D:\micro\LWork\VegetationHeight\Temporary\preprocessed\test_def.tif'
mas_arr = np.fromfile(mas, np.complex64)
aux_arr = np.fromfile(aux, np.complex64)
# mas_new = mas_arr.reshape(1307, 1900)
# aux_new = aux_arr.reshape(1307, 1900)
mas_new = mas_arr.reshape(6419, 5117)
aux_new = aux_arr.reshape(6419, 5117)
# mas_arr = ImageHandler.get_all_band_array(mas)
# aux_arr = ImageHandler.get_all_band_array(aux)
# mas_new = mas_arr[:,:,0] + mas_arr[:,:,1] * 1j
# aux_new = aux_arr[:,:,0] + aux_arr[:,:,1] * 1j
res = mas_new * np.conj(aux_new)
ang1 = np.angle(res, deg=False)
ImageHandler.write_img(out_file, '', [0, 0, 0, 0, 0, 0], ang1)
plt.imshow(ang1, cmap="hsv")
plt.colorbar()
plt.set_cmap(cmap)
plt.show()
def compute_flat_phase_estimate(sar_image):
# 假设sar_image是输入的SAR图像数据是一个二维的复数数组其中每个元素包含振幅和相位信息
# 首先计算SAR图像的幅度
sar_amplitude = np.abs(sar_image)
# 对幅度进行多普勒校正,这个步骤通常包括对图像进行配准和校正
# 这里仅仅做示例,实际情况下你可能需要更复杂的配准和校正步骤
sar_amplitude_corrected = sar_amplitude
# 计算多普勒校正后的SAR图像的相位
sar_phase = np.angle(sar_image)
# 使用信号处理中的方法例如2D FFT估计平地相位
# 在这个示例中我们使用3x3的中值滤波器来平滑相位图像
flat_phase_estimate = signal.medfilt(sar_phase, kernel_size=3)
plt.imshow(flat_phase_estimate[:,:,1], cmap="hsv")
plt.colorbar()
plt.set_cmap(cmap)
plt.show()
return flat_phase_estimate
if __name__ == '__main__':
show_filt()