利用下面代碼處理珞珈一號得到全黑影像,而且與源資料相缺少些屬性,求大佬指點

# -*- coding:utf-8 -*-
# -*-coding: cp936-*-
# coding=gbk
import cv2
import numpy as np
import math
def copy(img, new1):
new1 = np.zeros(img.shape, dtype='uint16')
new1[:, :] = img[:, :]
def computL(L, Dn, S):
Dn=pow(Dn,3/2)
S=pow(10,-10)
L=Dn*S
return (L)
if __name__ == '__main__':
img1 = cv2.imread('C:/Users/Gentry Long/Desktop/ygyg/LuoJia1-01_LR201903142986_20190311145935_HDR_0037_gec.tif',2)
print(img1)
# 影像格式轉換
img = cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY)
#imgFile='C:/Users/Gentry Long/Desktop/LuoJia1-01_LR201903142986_20190311145935_HDR_0037_gec.tif'
#img1 = cv2.imread(imgFile)
#if isinstance(img1, np.ndarray):
#pass
#else:
#print(img1)
#img=cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY)
# 計算JD
I = 2019
J = 3
K = 14
JD = K - 32075 + 1461 * (I + 4800 + (J - 14) / 12) / 4 + 367 * (J - 2 - (J - 14) / 12 * 12) / 12 - 3 * (
(I + 4900 + (J - 14) / 12) / 100) / 4
# 設定ESUNI值
ESUNI71 = 196.9
# 計算日地距離D
D = 1 - 0.01674 * math.cos((0.9856 * (JD - 4) * math.pi / 180))
# 計算太陽天頂角
cos = math.cos(math.radians(90 - 41.3509605))
inter = (math.pi * D * D) / (ESUNI71 * cos * cos)
# 大氣校正引數設定
Lmini = -6.2
Lmax = 293.7
Qcal = 1
Qmax = 255
LIMIN = Lmini + (Qcal * (Lmax - Lmini) / Qmax)
LI = (0.01 * ESUNI71 * cos * cos) / (math.pi * D * D)
Lhazel = LIMIN - LI
print('D=', D)
print('cosZS=', cos)
print('Lhazel=', Lhazel)
# 計算影像反射率
result = np.zeros(img.shape, dtype='uint16')
for i in range(0, img.shape[0]):
for j in range(0, img.shape[0]):
Lsat = computL(1.18070871, img[i, j], -7.38070852)
result[i, j] = inter * (Lsat - Lhazel) * 1000
# 保存影像
cv2.imwrite("D:\\result.tif", result)
cv2.namedWindow("Image")
cv2.imshow("Image", result)
cv2.waitKey(0)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/124981.html
