pyfusion.utils package

Module contents

pyfusion.utils.Entropy(src)[源代码]

计算影像的信息熵

The Entropy will calculate the information entropy of image

参数

src – source image, it should be read by cv2.imread() and grayscale image

返回

信息熵

返回类型

float

class pyfusion.utils.Image(image=None)[源代码]

基类:object

Image`是一个自定义的类。有两个需要注意的属性——`image`和`data

image`是一个`osgeo.gdal.Dataset`类型的属性,是用`gdal.Opengdal.OpenEx 或者 `gdal.OpenShared`读出来的数据集,这个属性存储了影像的metadata

`data`是一个`numpy.array`类型的属性,如果你不修改的话,只会从硬盘中将影像读出来。当然也可以赋值

如果直接用`osgeo.gdal.Dataset.ReadAsArray`读出来的像素的shape是(bands, width, height)这样的。类中将shape转成了(width, height, bands),因为opencv使用的这样的shape

Attributes:

image: the image metadata.

data: the value of the pixel.

property data
property image
toGeoTiff(filepath: str)[源代码]

保存文件成GeoTiff格式

将影像保存成GeoTiff格式的文件,有一些地方需要注意

影像文件基于`data`属性的,也就是说`image`属性只管metadata,影像的像素值是由`data`决定的

影像的长宽,波段数都要和`data`的shape对应上

pyfusion.utils.RMSE(src, pan)[源代码]

计算影像的RMSE

参数

src – source image, it should be read by cv2.imread() and grayscale image

返回

RMSE

返回类型

float

pyfusion.utils.R_value(src, pan)[源代码]

计算影像的相关性系数

参数

src – source image, it should be read by cv2.imread() and grayscale image

返回

R value

返回类型

float

pyfusion.utils.ReadImageFile(filepath: str)[源代码]

Read image

用`gdal.OpenShared`读的只读影像

参数

filepath – The file path

返回

Image

返回类型

pyfusion.utils.Image

pyfusion.utils.avg_grad(src)[源代码]

计算影像的平均梯度

参数

src – source image, it should be read by cv2.imread() and grayscale image

返回

average gradient

返回类型

float

pyfusion.utils.histMatch(src, ref)[源代码]

直方图匹配

histMatch函数将会返回以`ref`影像为基准的匹配影像,`src`和`ref`都应该为灰度影像

参数
  • src – 源影像,应该为`numpy.ndarry`的数据结构,应该使用`opencv`包来读入

  • ref – 参考影像,应该为`numpy.ndarry`的数据结构,应该使用`opencv`包来读入

返回

结果影像

返回类型

numpy.ndarray

pyfusion.utils.histMatch2(src, ref)[源代码]

直方图匹配

histMatch2函数功能与histMatch函数类似,但这个处理的不是8位的影像,PCA融合时需要使用

参数
  • src – 源影像,应该为`numpy.ndarry`的数据结构,应该使用`opencv`包来读入

  • ref – 参考影像,结构为`numpy.ndarry`,dtype为`numpy.float32`

返回

结果影像

返回类型

numpy.ndarray

pyfusion.utils.judge(img, pan=None)[源代码]

计算`img`影像的一些信息

The img should be a grayscale image

参数
  • img – The image

  • pan – The pan image

返回

Some infomation

返回类型

dict

pyfusion.utils.piancha_relativepiancha(src, pan)[源代码]
pyfusion.utils.scala_image(img, rg)[源代码]