import cv2
import numpy as np
[文件]def Brovery(src, pan):
"""Using Brovery method to fusion image
The source image should not be upsampled
:param src: `source` image, the image should be BGR color space
:param pan: Panchromatic image, the image should be grayscale
:return: fusion image
:rtype: `numpy.ndarray`
"""
img_bgr = cv2.resize(src, pan.shape)
pan = pan.astype(np.float32)
b,g,r = cv2.split(img_bgr)
b = b.astype(np.float32)
g = g.astype(np.float32)
r = r.astype(np.float32)
rf = (3*pan)*r/(b+g+r)
gf = (3*pan)*g/(b+g+r)
bf = (3*pan)*b/(b+g+r)
bf = bf.astype(np.uint8)
gf = gf.astype(np.uint8)
rf = rf.astype(np.uint8)
img_brovery = cv2.merge((bf,gf,rf))
return img_brovery