参考了网上不少RGB到HSI转换代码
https://blog.youkuaiyun.com/qq_38328871/article/details/85060459
https://blog.youkuaiyun.com/qq_30091945/article/details/78236347
https://blog.youkuaiyun.com/lwplwf/article/details/77494072
但直接跑起来,效率比较低,原因是用了循环。毕竟是Python,效率不能和C/C++相比。用numpy数组计算效率提高很多。公式参考其他博客,这里不写了,直接贴代码
import numpy as np
import tifffile
import cv2
from matplotlib import pyplot as plt
def Normalize(band):
res = (band - np.min(band)) / (np.max(band) - np.min(band))
return res
def rgb2hsi_np(R, G, B):
# 波段归一化
B = Normalize(B)
G = Normalize(G)
R = Normalize(R)
rows = B.shape[0]
cols = B.shape[