The common evaluation Index of hyperspectral image reconstruction and its Python implementation

Source: Internet
Author: User

Evaluation index of hyperspectral image reconstruction and its Python implementation

The evaluation index of hyperspectral image reconstruction usually has three items. Some of these indicators change from the ordinary image, some of the indicators only hyperspectral images unique. This paper intends to introduce the Hyperspectral image Evaluation index from the following two angles, and lists the corresponding implementation method of Skimage library based on Python language.

1) from the normal Image reconstruction evaluation Index to hyperspectral Image Reconstruction Evaluation Index

2) from normal image reconstruction evaluation indicator code to hyperspectral Image Reconstruction evaluation Index code

First, MSE

MSE calculates the mean square error of two sets of data, and is the most commonly used criterion for evaluating similarity, including but not limited to images and signals.

The corresponding function prototypes in the Skimage library:

skimage.measure.compare_mse(im1, im2)

Parameters:

im1, im2 : Ndarray

Image. Any dimensionality.

Returns:

MSE : Float

The mean-squared error (MSE) metric.

To measure other distances, refer to the COMPARE_NRMSE function

Http://scikit-image.org/docs/stable/api/skimage.measure.html#compare-nrmse

Second, Psnr and MPSNR1. Psnr

PSNR full name is compute the peak signal to noise ratio. Used to calculate the peak signal-to-noise ratio between the original image and the reconstructed image. In the image super-resolution and other tasks are particularly common, as the error rate of the classification task, Psnr is the image reconstruction task in fact the benchmark evaluation criteria.

Skimage.measure.compare_psnr (Im_true, Im_test, Data_range=none, Dynamic_range =none)

Parameters:

im_true : Ndarray

Ground-truth image.

im_test : Ndarray

Test image.

data_range : int

The data range of the input image (distance between minimum and maximum possible values). By default, this is estimated from the image data-type.

Returns:

Psnr : Float

The PSNR metric.

2. Mpsnr

The Mpsnr is used to calculate the average peak signal-to-noise ratio between two hyperspectral images. Mpsnr calculation method is very simple, only need to calculate the Psnr of different bands separately, take the mean value can be.

1 defMpsnr (X_true, x_pred):2     """3 4 :p Aram X_true: hyperspectral Images: Format: (H, W, C)5 :p Aram x_pred: hyperspectral Images: Format: (H, W, C)6 : Return: Calculates the mean square error of the original hyperspectral data and the reconstructed hyperspectral data7 References8     ----------9     .. [1] https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratioTen     """ OneN_bands = x_true.shape[2] Ap = [Compare_psnr (x_true[:,:, K], x_pred[:,:, K], Dynamic_range=np.max (x_true[:,:, K])) forKinchrange (n_bands)] -     returnNp.mean (P)

Third, Ssim and MSSIM1. The Ssim is used to calculate the average structural similarity between two images.

skimage.measure.compare_ssim(X, Y, win_size=none, gradient=false, data_range=none, Multichannel=false, gaussian_weights=false, full=false, dynamic_range=none, * *kwargs)

Parameters:

X, Y : Ndarray

Image. Any dimensionality.

win_size : int or None

The side-length of the sliding window used in comparison. Must is an odd value. If gaussian_weights is True, the ignored and the window size would depend on Sigma.

gradient : bool, optional

If True, also return the gradient.

data_range : int, optional

The data range of the input image (distance between minimum and maximum possible values). By default, this is estimated from the image data-type.

multichannel : bool, optional

If True, treat the last dimension of the array as channels. Similarity calculations is do independently for each channel then averaged.

gaussian_weights : bool, optional

If True, each patch have its mean and variance spatially weighted by a normalized Gaussian kernel of width sigma=1.5.

full: bool, optional

If True, return the full structural similarity image instead of the mean value.

Returns:

MsSIM : Float

The mean structural similarity over the image.

Grad : Ndarray

The gradient of the structural similarity index between X and Y [R327]. This was only returned if gradient are set to True.

S : Ndarray

The full ssim image. This is the only returned if-is set to True.

Other Parameters:

use_sample_covariance : BOOL

If True, normalize covariances by N-1 rather than, n where n is the number of pixels within the sliding window.

K1 : Float

Algorithm parameter, K1 (small constant, see [R326])

K2 : Float

Algorithm parameter, K2 (small constant, see [R326])

Sigma : Float

Sigma for the Gaussian if gaussian_weights is True.

2. MsSIM

The MsSIM is used to calculate the average structural similarity between two hyperspectral images. MsSIM calculation method is very simple, only need to calculate the Ssim index of different bands separately, take the mean value can be.

1 def MsSIM (x_true,x_pred): 2     """ 3         :p Aram X_true: hyperspectral Images: Format: (H, W, c)4        :p Aram x_pred: hyperspectral Images: Format: (H, W, c)5          : return: Calculate the structural similarity between the original hyperspectral data and the reconstructed hyperspectral data 6     ""7     Ssim = Compare_ssim (X=x_true, y=x_pred, multichannel=true)8     return Ssim

Iv. SAM

The concept of Sam is only present in the multi/Highlight spectral image, which does not have a common image. Sam, also known as spectral angle similarity, is used to measure the spectral similarity between the original hyperspectral data and the reconstructed hyperspectral data.

1 defSam (X_true, x_pred):2     """3 :p Aram X_true: hyperspectral Images: Format: (H, W, C)4 :p Aram x_pred: hyperspectral Images: Format: (H, W, C)5 : return: Calculate spectral angle similarity between the original hyperspectral data and the reconstructed hyperspectral data6     """7     assertX_true.ndim ==3 andX_true.shape = =X_pred.shape8Sam_rad = Np.zeros (x_pred.shape[0, 1])9      forXinchRange (X_true.shape[0]):Ten          forYinchRange (x_true.shape[1]): Onetmp_pred =x_pred[x, Y].ravel () ATmp_true =x_true[x, Y].ravel () -Sam_rad[x, Y] = Np.arccos (tmp_pred/(Norm (tmp_pred) * Tmp_true/Norm (tmp_true))) -Sam_deg = Sam_rad.mean () * 180/Np.pi the     returnSam_deg

V. Related INFORMATION 0. The code used in the article

Https://github.com/JiJingYu/tensorflow-exercise/tree/master/HSI_evaluate

1. Documentation of the functions mentioned in the article

Http://scikit-image.org/docs/stable/api/skimage.measure.html#compare-mse

2. Psnr Wikipedia link Https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio3. Ssim Reference Documents

[R326] Wang, Z., Bovik, A. C., Sheikh, H. R. R., & Simoncelli, E. P. (2004). Image Quality Assessment:from error visibility to structural similarity. IEEE transactions on Image processing, 13, 600-612. Https://ece.uwaterloo.ca/~z70wang/publications/ssim.pdf, doi:10.1.1.11.2477

[R327] Avanaki, A. N. (2009). Exact Global histogram specification optimized for structural similarity. Optical Review, 16, 613-621. http://arxiv.org/abs/0901.0065, Doi:10.1007/s10043-009-0119-z

The common evaluation Index of hyperspectral image reconstruction and its Python implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.