pyfusion.utils package¶
Submodules¶
pyfusion.utils.histMatch module¶
-
pyfusion.utils.histMatch.
histMatch
(src, ref)[source]¶ Histogram matching
The histMatch function will return the image been matched by ref, the src and ref should be grayscale image
- Parameters
src – The source image, it should be numpy.ndarray structure, the image read by opencv would be best practice
ref – The reference image, it should be numpy.ndarray structure, the image read by opencv would be best practice
- Returns
The result image
- Return type
numpy.ndarray
-
pyfusion.utils.histMatch.
histMatch2
(src, ref)[source]¶ Histogram matching
The histmatch2 function will return the image which matched by reference image, the source and reference image will not be 8-bit image, it used by PCA fusion
- Parameters
src – The source image, it should be numpy.ndarray structure, the image read by opencv would be best practice
ref – The reference image, it should be numpy.ndarray structure, the dtype would be numpy.float32
- Returns
The result image
- Return type
numpy.ndarray
pyfusion.utils.judge module¶
pyfusion.utils.utils module¶
-
pyfusion.utils.utils.
Entropy
(src)[source]¶ Calculate the information entropy of source image.
The Entropy will calculate the information entropy of image
- Parameters
src – source image, it should be read by cv2.imread() and grayscale image
- Returns
information entropy
- Return type
float
-
class
pyfusion.utils.utils.
Image
(image=None)[source]¶ Bases:
object
Image is a custom class. There are two import attributes: image and data.
The image is a osgeo.gdal.Dataset type attribute, it should be read by gdal.Open, gdal.OpenEx or gdal.OpenShared, it store the metadata of the image.
The data is a numpy.array type attribute, if you not modify it, it just read the image on disk. You also can set it by assignment.
If you direct read the pixel by osgeo.gdal.Dataset.ReadAsArray, the shape is (bands, width, height). I transform it to (width, height, bands) because the cv2.imread will make the data’s shape like this.
- Attributes:
image: the image metadata data: the value of the pixel
-
property
data
¶
-
property
image
¶
-
toGeoTiff
(filepath: str)[source]¶ Save image to disk
This fuction can save the image to GeoTiff file. There are some points should be attentioned.
The image file is based on data attribute. It means the image can only control the metadata and the value of the pixel is determined by the data.
The image width and height should be equal to the data shape. Also the band number is.
-
pyfusion.utils.utils.
RMSE
(src, pan)[source]¶ Calculate RMSE of source image
- Parameters
src – source image, it should be read by cv2.imread() and grayscale image
- Returns
RMSE
- Return type
float
-
pyfusion.utils.utils.
R_value
(src, pan)[source]¶ Calculate the R squared value
- Parameters
src – source image, it should be read by cv2.imread() and grayscale image
- Returns
R value
- Return type
float
-
pyfusion.utils.utils.
ReadImageFile
(filepath: str)[source]¶ Read image
It will read the image using gdal.OpenShared in read-only mode.
- Parameters
filepath – The file path
- Returns
Image
- Return type
pyfusion.utils.Image
Module contents¶
-
pyfusion.utils.
Entropy
(src)[source]¶ Calculate the information entropy of source image.
The Entropy will calculate the information entropy of image
- Parameters
src – source image, it should be read by cv2.imread() and grayscale image
- Returns
information entropy
- Return type
float
-
class
pyfusion.utils.
Image
(image=None)[source]¶ Bases:
object
Image is a custom class. There are two import attributes: image and data.
The image is a osgeo.gdal.Dataset type attribute, it should be read by gdal.Open, gdal.OpenEx or gdal.OpenShared, it store the metadata of the image.
The data is a numpy.array type attribute, if you not modify it, it just read the image on disk. You also can set it by assignment.
If you direct read the pixel by osgeo.gdal.Dataset.ReadAsArray, the shape is (bands, width, height). I transform it to (width, height, bands) because the cv2.imread will make the data’s shape like this.
- Attributes:
image: the image metadata data: the value of the pixel
-
property
data
¶
-
property
image
¶
-
toGeoTiff
(filepath: str)[source]¶ Save image to disk
This fuction can save the image to GeoTiff file. There are some points should be attentioned.
The image file is based on data attribute. It means the image can only control the metadata and the value of the pixel is determined by the data.
The image width and height should be equal to the data shape. Also the band number is.
-
pyfusion.utils.
RMSE
(src, pan)[source]¶ Calculate RMSE of source image
- Parameters
src – source image, it should be read by cv2.imread() and grayscale image
- Returns
RMSE
- Return type
float
-
pyfusion.utils.
R_value
(src, pan)[source]¶ Calculate the R squared value
- Parameters
src – source image, it should be read by cv2.imread() and grayscale image
- Returns
R value
- Return type
float
-
pyfusion.utils.
ReadImageFile
(filepath: str)[source]¶ Read image
It will read the image using gdal.OpenShared in read-only mode.
- Parameters
filepath – The file path
- Returns
Image
- Return type
pyfusion.utils.Image
-
pyfusion.utils.
avg_grad
(src)[source]¶ Calculate the average gradient of source image
- Parameters
src – source image, it should be read by cv2.imread() and grayscale image
- Returns
average gradient
- Return type
float
-
pyfusion.utils.
histMatch
(src, ref)[source]¶ Histogram matching
The histMatch function will return the image been matched by ref, the src and ref should be grayscale image
- Parameters
src – The source image, it should be numpy.ndarray structure, the image read by opencv would be best practice
ref – The reference image, it should be numpy.ndarray structure, the image read by opencv would be best practice
- Returns
The result image
- Return type
numpy.ndarray
-
pyfusion.utils.
histMatch2
(src, ref)[source]¶ Histogram matching
The histmatch2 function will return the image which matched by reference image, the source and reference image will not be 8-bit image, it used by PCA fusion
- Parameters
src – The source image, it should be numpy.ndarray structure, the image read by opencv would be best practice
ref – The reference image, it should be numpy.ndarray structure, the dtype would be numpy.float32
- Returns
The result image
- Return type
numpy.ndarray