Class ImageQuality

All Implemented Interfaces:
ActionListener, WindowListener, Runnable, EventListener

public class ImageQuality extends AlgorithmBase
Author:
aailb MIT License imageQualityIndex.m by Zhou Wang ported with his kind permission. The original source code for imageQualityIndex.m is Copyright (c) 2001 The University of Texas at Austin ssim_index.m and ssim.m by Zhou Wang ported with his kind permission. The original source code for ssim.index.m is Copyright(c) 2003 Zhou Wang The original source code for ssim.m is Copyright(c) 2009 Zhou Wang msssim.m and ssim_index.new.m by Zhou Wang ported with his kind permission. For VISUAL_INFORMATION_FIDELITY: % -----------COPYRIGHT NOTICE STARTS WITH THIS LINE------------ % Copyright (c) 2005 The University of Texas at Austin % All rights reserved. % % Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, % modify, and distribute this code (the source files) and its documentation for % any purpose, provided that the copyright notice in its entirety appear in all copies of this code, and the % original source of this code, Laboratory for Image and Video Engineering (LIVE, http://live.ece.utexas.edu) % at the University of Texas at Austin (UT Austin, % http://www.utexas.edu), is acknowledged in any publication that reports research using this code. The research % is to be cited in the bibliography as: % % H. R. Sheikh and A. C. Bovik, "Image Information and Visual Quality", IEEE Transactions on % Image Processing, (to appear). % % IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT AUSTIN BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, % OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS DATABASE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF TEXAS % AT AUSTIN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. % % THE UNIVERSITY OF TEXAS AT AUSTIN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED % WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE DATABASE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, % AND THE UNIVERSITY OF TEXAS AT AUSTIN HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. % % -----------COPYRIGHT NOTICE ENDS WITH THIS LINE------------ % %This is an implementation of the algorithm for calculating the %Visual Information Fidelity (VIF) measure (may also be known as the Sheikh %-Bovik Index) between two images. Please refer %to the following paper: % %H. R. Sheikh and A. C. Bovik "Image Information and Visual Quality" %IEEE Transactios on Image Processing, in publication, May 2005. %Download manuscript draft from http://live.ece.utexas.edu in the %Publications link % %This implementation is slightly differnet from the one used to report %results in the paper above. The modification have to do with using more %subands than those used in the paper, better handling of image boundaries, %and a window that automatically resizes itself based on the scale. % %Report bugfixes and comments to hamid.sheikh@ieee.org % %---------------------------------------------------------------------- % Prerequisites: The Steerable Pyramid toolbox. Available at % http://www.cns.nyu.edu/~lcv/software.html % %Input : (1) img1: The reference image % (2) img2: The distorted image (order is important) % %Output: (1) VIF te visual information fidelity measure between the two images %Default Usage: % Given 2 test images img1 and img2, whose dynamic range is 0-255 % % vif = vifvec(img1, img2); % %Advanced Usage: % Users may want to modify the parameters in the code. % (1) Modify sigma_nsq to find tune for your image dataset. % (2) MxM is the block size that denotes the size of a vector used in the % GSM model. % (3) subbands included in the computation NQM is ported with the kind permission of Professor Brian L. Evans: Copyright (c) 1999-2021 The University of Texas at Austin All rights reserved. Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the copyright notice in its entirety appear in all copies of this software. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT AUSTIN BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF TEXAS AT AUSTIN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF TEXAS AT AUSTIN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE DATABASE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF TEXAS AT AUSTIN HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. VSR is ported with the kind permissions of Dr. Sheila S. Hemami and Professor Damon Chandler at Ritsumeikan University in Japan. They are the co_inventors of the method. Author: D. M. Chander Copyright 1998-2007 Image Coding and Analysis Lab, Oklahoma State University, Stillwater, OK 74078 USA. $Revision: BETA 1.02.0.0 $ $Date: 2007/10/04/ 15:00:00 $ For DWT code used for VSNR: //////////////////////////////////////////////////////////////////////////// // // // COPYRIGHT (c) 1998, 2002, VCL // // ------------------------------ // // Permission to use, copy, modify, distribute and sell this software // // and its documentation for any purpose is hereby granted without fee, // // provided that the above copyright notice appear in all copies and // // that both that copyright notice and this permission notice appear // // in supporting documentation. VCL makes no representations about // // the suitability of this software for any purpose. // // // // DISCLAIMER: // // ----------- // // The code provided hereunder is provided as is without warranty // // of any kind, either express or implied, including but not limited // // to the implied warranties of merchantability and fitness for a // // particular purpose. The author(s) shall in no event be liable for // // any damages whatsoever including direct, indirect, incidental, // // consequential, loss of business profits or special damages. // // // Other metrics are from full_ref.py, no_ref.py and utils.py by Andrew Khalel. full_ref.py, no_ref.py and utils.py are Copyright (c) 2018 Andrew Khalel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## Implemented metrics - [x] Mean Squared Error (MSE) - [x] Root Mean Squared Error (RMSE) - [x] Peak Signal-to-Noise Ratio (PSNR) [[1]](https://ieeexplore.ieee.org/abstract/document/1284395/) - [x] Structural Similarity Index (SSIM) [[1]](https://ieeexplore.ieee.org/abstract/document/1284395/) - [x] Universal Quality Image Index (UQI) [[2]](https://ieeexplore.ieee.org/document/995823/) - [x] Multi-scale Structural Similarity Index (MS-SSIM) [[3]](https://ieeexplore.ieee.org/abstract/document/1292216/) - [x] Erreur Relative Globale Adimensionnelle de Synthese (ERGAS) [[4]](https://hal.archives-ouvertes.fr/hal-00395027/) - [x] Spatial Correlation Coefficient (SCC) [[5]](https://www.tandfonline.com/doi/abs/10.1080/014311698215973) - [x] Relative Average Spectral Error (RASE) [[6]](https://ieeexplore.ieee.org/document/1304896/) - [x] Spectral Angle Mapper (SAM) [[7]](https://ntrs.nasa.gov/search.jsp?R=19940012238) - [x] Spectral Distortion Index (D_lambda) [[8]](https://www.ingentaconnect.com/content/asprs/pers/2008/00000074/00000002/art00003) - [x] Spatial Distortion Index (D_S) [[8]](https://www.ingentaconnect.com/content/asprs/pers/2008/00000074/00000002/art00003) - [x] Quality with No Reference (QNR) [[8]](https://www.ingentaconnect.com/content/asprs/pers/2008/00000074/00000002/art00003) - [x] Visual Information Fidelity (VIF) [[9]](https://ieeexplore.ieee.org/abstract/document/1576816/) - [x] Block Sensitive - Peak Signal-to-Noise Ratio (PSNR-B) [[10]](https://ieeexplore.ieee.org/abstract/document/5535179/) Available metrics list mse, rmse, psnr, rmse_sw, uqi, ssim, ergas, scc, rase, sam, msssim, vifp, psnrb ## References [1] "Image quality assessment: from error visibility to structural similarity." 2004)
[2] "A universal image quality index." (2002)
[3] "Multiscale structural similarity for image quality assessment." (2003)
[4] "Quality of high resolution synthesised images: Is there a simple criterion?." (2000)
[5] "A wavelet transform method to merge Landsat TM and SPOT panchromatic data." (1998)
[6] "Fusion of multispectral and panchromatic images using improved IHS and PCA mergers based on wavelet decomposition." (2004)
[7] "Discrimination among semi-arid landscape endmembers using the spectral angle mapper (SAM) algorithm." (1992)
[8] "Multispectral and panchromatic data fusion assessment without reference." (2008)
[9] "Image information and visual quality." (2006)
[10] "Quality Assessment of Deblocked Images" (2011)
  • Field Details

    • UI

      private ViewUserInterface UI
    • metrics

      private int[] metrics
    • results

      private double[] results
    • referenceImage

      private ModelImage referenceImage
    • testImage

      private ModelImage testImage
    • MEAN_SQUARED_ERROR

      public final int MEAN_SQUARED_ERROR
      See Also:
    • ROOT_MEAN_SQUARED_ERROR

      public final int ROOT_MEAN_SQUARED_ERROR
      See Also:
    • PEAK_SIGNAL_TO_NOISE_RATIO

      public final int PEAK_SIGNAL_TO_NOISE_RATIO
      See Also:
    • STRUCTURAL_SIMILARITY_INDEX

      public final int STRUCTURAL_SIMILARITY_INDEX
      See Also:
    • SSIM_WITH_AUTOMATIC_DOWNSAMPLING

      public final int SSIM_WITH_AUTOMATIC_DOWNSAMPLING
      See Also:
    • UNIVERSAL_QUALITY_IMAGE_INDEX

      public final int UNIVERSAL_QUALITY_IMAGE_INDEX
      See Also:
    • MULTI_SCALE_STRUCTURAL_SIMILARITY_INDEX

      public final int MULTI_SCALE_STRUCTURAL_SIMILARITY_INDEX
      See Also:
    • ERGAS

      public final int ERGAS
      See Also:
    • SPATIAL_CORRELATION_COEFFICIENT

      public final int SPATIAL_CORRELATION_COEFFICIENT
      See Also:
    • RELATIVE_AVERAGE_SPECTRAL_ERROR

      public final int RELATIVE_AVERAGE_SPECTRAL_ERROR
      See Also:
    • SPECTRAL_ANGLE_MAPPER

      public final int SPECTRAL_ANGLE_MAPPER
      See Also:
    • VISUAL_INFORMATION_FIDELITY

      public final int VISUAL_INFORMATION_FIDELITY
      See Also:
    • PIXEL_BASED_VISUAL_INFORMATION_FIDELITY

      public final int PIXEL_BASED_VISUAL_INFORMATION_FIDELITY
      See Also:
    • BLOCK_SENSITIVE_PEAK_SIGNAL_TO_NOISE_RATIO

      public final int BLOCK_SENSITIVE_PEAK_SIGNAL_TO_NOISE_RATIO
      See Also:
    • RMSE_SW

      public final int RMSE_SW
      See Also:
    • NQM

      public final int NQM
      See Also:
    • VSNR

      public final int VSNR
      See Also:
    • PRODUCT

      private static final int PRODUCT
      See Also:
    • WTD_SUM

      private static final int WTD_SUM
      See Also:
    • testBuffer

      private double[] testBuffer
    • testRedBuffer

      private float[] testRedBuffer
    • testGreenBuffer

      private float[] testGreenBuffer
    • testBlueBuffer

      private float[] testBlueBuffer
    • referenceBuffer

      private double[] referenceBuffer
    • referenceRedBuffer

      private float[] referenceRedBuffer
    • referenceGreenBuffer

      private float[] referenceGreenBuffer
    • referenceBlueBuffer

      private float[] referenceBlueBuffer
    • testYBuffer

      private double[] testYBuffer
    • referenceYBuffer

      private double[] referenceYBuffer
    • rmse_sw_mean

      private double rmse_sw_mean
    • universalImageQualityIndex

      private double universalImageQualityIndex
    • structuralSimilarityIndex

      private double structuralSimilarityIndex
    • overall_mssim

      private double overall_mssim
    • sam_mean

      private double sam_mean
    • psnr_b

      private double psnr_b
    • length

      private int length
    • YCrCbRequired

      private boolean YCrCbRequired
    • isColor

      private boolean isColor
    • meanSquareError

      private double meanSquareError
    • meanRedSquareError

      private double meanRedSquareError
    • meanGreenSquareError

      private double meanGreenSquareError
    • meanBlueSquareError

      private double meanBlueSquareError
    • rootMeanSquareError

      private double rootMeanSquareError
    • peakSignalToNoiseRatio

      private double peakSignalToNoiseRatio
    • rmse_map

      private double[][] rmse_map
    • rmse_red_map

      private double[][] rmse_red_map
    • rmse_green_map

      private double[][] rmse_green_map
    • rmse_blue_map

      private double[][] rmse_blue_map
    • ergas_mean

      private double ergas_mean
    • spatialCorrelationCoefficient

      private double spatialCorrelationCoefficient
    • rase_mean

      private double rase_mean
    • vifp_mean

      private double vifp_mean
    • vif

      private double vif
    • nqm_value

      private double nqm_value
    • vsnr_value

      private double vsnr_value
    • gry

      private ModelImage gry
    • gry_noise

      private ModelImage gry_noise
    • gry_const

      private ModelImage gry_const
    • clr

      private ModelImage clr
    • clr_noise

      private ModelImage clr_noise
    • clr_const

      private ModelImage clr_const
    • nDims

      private int nDims
    • xDim

      private int xDim
    • yDim

      private int yDim
    • ws

      private int ws
    • k1

      private double k1
    • k2

      private double k2
    • sigma

      private double sigma
    • level

      private int level
    • weight

      private double[] weight
    • method

      private int method
    • r

      private double r
    • win

      private double[][] win
    • sigma_nsq

      private double sigma_nsq
    • subbands

      private int[] subbands
    • M

      private int M
    • VA

      private double VA
    • alpha

      private double alpha
    • vsnr_data_b

      private int vsnr_data_b
    • vsnr_data_k

      private double vsnr_data_k
    • vsnr_data_g

      private double vsnr_data_g
    • vsnr_data_r

      private double vsnr_data_r
    • vsnr_data_v

      private double vsnr_data_v
    • vsnr_data_num_levels

      private int vsnr_data_num_levels
    • vsnr_data_filter_gains

      private int[] vsnr_data_filter_gains
    • vsnr_data_fs

      private double[] vsnr_data_fs
    • vsnr_data_pix2lum_table

      private double[] vsnr_data_pix2lum_table
    • vsnr_data_CTe

      private double vsnr_data_CTe
    • vsnr_data_mX

      private double vsnr_data_mX
    • vsnr_data_mL

      private double vsnr_data_mL
    • vsnr_data_zeta

      private double vsnr_data_zeta
    • vsnr_data_Cis

      private double[] vsnr_data_Cis
    • vsnr_data_Ci

      private double vsnr_data_Ci
    • vsnr_data_Ce

      private double vsnr_data_Ce
    • BORDER_CONSTANT

      public final int BORDER_CONSTANT
      See Also:
    • BORDER_REPLICATE

      public final int BORDER_REPLICATE
      See Also:
    • BORDER_REFLECT

      public final int BORDER_REFLECT
      See Also:
    • BORDER_WRAP

      public final int BORDER_WRAP
      See Also:
    • BORDER_REFLECT_101

      public final int BORDER_REFLECT_101
      See Also:
    • BORDER_DEFAULT

      public final int BORDER_DEFAULT
      See Also:
    • ALPHA

      static final double ALPHA
      See Also:
    • BETA

      static final double BETA
      See Also:
    • GAMMA

      static final double GAMMA
      See Also:
    • DELTA

      static final double DELTA
      See Also:
    • TWOALPHA

      static final double TWOALPHA
      See Also:
    • TWOBETA

      static final double TWOBETA
      See Also:
    • TWOGAMMA

      static final double TWOGAMMA
      See Also:
    • TWODELTA

      static final double TWODELTA
      See Also:
    • GWAVELIFT_NORM_1_1

      boolean GWAVELIFT_NORM_1_1
  • Constructor Details

    • ImageQuality

      public ImageQuality()
    • ImageQuality

      public ImageQuality(ModelImage referenceImage, ModelImage testImage, int[] metrics, double[] results)
    • ImageQuality

      public ImageQuality(ModelImage referenceImage, ModelImage testImage, int[] metrics, int ws, double[] results)
    • ImageQuality

      public ImageQuality(ModelImage referenceImage, ModelImage testImage, int[] metrics, int ws, double k1, double k2, double sigma, double[] results)
    • ImageQuality

      public ImageQuality(ModelImage referenceImage, ModelImage testImage, int[] metrics, int ws, double k1, double k2, double sigma, int level, double[] weight, int method, double[] results)
    • ImageQuality

      public ImageQuality(ModelImage referenceImage, ModelImage testImage, int[] metrics, int ws, double r, double[] results)
    • ImageQuality

      public ImageQuality(ModelImage referenceImage, ModelImage testImage, int[] metrics, int ws, double[][] win, double[] results)
    • ImageQuality

      public ImageQuality(ModelImage referenceImage, ModelImage testImage, int[] metrics, double sigma_nsq, double[] results)
    • ImageQuality

      public ImageQuality(ModelImage referenceImage, ModelImage testImage, int[] metrics, double sigma_nsq, int[] subbands, int M, double[] results)
    • ImageQuality

      public ImageQuality(ModelImage referenceImage, ModelImage testImage, double VA, int[] metrics, double[] results)
    • ImageQuality

      public ImageQuality(ModelImage referenceImage, ModelImage testImage, int[] metrics, double alpha, int vsnr_data_b, double vsnr_data_k, double vsnr_data_g, double vsnr_data_r, double vsnr_data_v, int vsnr_data_num_levels, int[] vsnr_data_filter_gains, double[] results)
    • ImageQuality

      public ImageQuality(ModelImage referenceImage, ModelImage testImage, int[] metrics, int ws, double k1, double k2, double sigma, double r, double[][] win, double sigma_nsq, int[] subbands, int M, int level, double[] weight, int method, double VA, double alpha, int vsnr_data_b, double vsnr_data_k, double vsnr_data_g, double vsnr_data_r, double vsnr_data_v, int vsnr_data_num_levels, int[] vsnr_data_filter_gains, double[] results)
  • Method Details

    • testMse

      public void testMse()
    • testRmse

      public void testRmse()
    • testPsnr

      public void testPsnr()
    • testErgas

      public void testErgas()
    • testScc

      public void testScc()
    • testRase

      public void testRase()
    • testUqi

      public void testUqi()
    • testSsim

      public void testSsim()
    • testSsimDownload

      public void testSsimDownload()
    • testMsssim

      public void testMsssim()
    • testSam

      public void testSam()
    • testNQM

      public void testNQM()
    • testPSNRB

      public void testPSNRB()
    • testVIF

      public void testVIF()
    • testVIFP

      public void testVIFP()
    • testVSNR

      public void testVSNR()
    • runAlgorithm

      public void runAlgorithm()
      Description copied from class: AlgorithmBase
      Actually runs the algorithm. Implemented by inheriting algorithms.
      Specified by:
      runAlgorithm in class AlgorithmBase
    • mse

      private void mse()
    • rmse

      private void rmse()
    • psnr

      private void psnr()
    • copyMakeBorder

      public double[][] copyMakeBorder(double[][] src, int top, int bottom, int left, int right, int borderType, double borderValue)
    • filter2Same

      private double[][] filter2Same(double[][] img, double[][] win)
    • correlationFilter

      private double[][] correlationFilter(double[][] img)
    • uniformFilter

      private double[][] uniformFilter(double[][] img, int size1, int size2)
    • rmse_sw

      private void rmse_sw()
    • filter2Valid

      private double[][] filter2Valid(double[][] img, double[][] filter)
    • ergas

      private void ergas()
    • scc

      private void scc()
    • rase

      private void rase()
    • uqi

      private void uqi()
    • msssim

      private void msssim()
    • ssim

      private void ssim(boolean downSampling)
    • sam

      private void sam()
    • psnrb

      private void psnrb()
    • _compute_bef

      private double _compute_bef(double[] im, int block_size)
    • log2

      private double log2(double input)
    • vifp

      private void vifp()
    • vifvec

      private void vifvec()
    • refparams_vecgsm

      private void refparams_vecgsm(double[][][] ssarr, double[][] l_arr, Vector<double[][]> org)
    • filter2SameWithDownSample

      private double[][] filter2SameWithDownSample(double[][] img, double[][] win, int borderType, int downSampleY, int downSampleX, int startY, int startX, int stopY, int stopX)
    • vifsub_est_M

      private void vifsub_est_M(Vector<double[][]> g_all, Vector<double[][]> vv_all, Vector<double[][]> org, Vector<double[][]> dist)
    • nqm

      private void nqm()
    • gthresh

      private double[] gthresh(double[] x, double T, double[] z)
    • cmaskn

      private double[] cmaskn(double[] c, double[] ci, double[] a, double[] ai, double i)
    • ctf

      private double ctf(double f_r)
    • fftshift

      private double[][] fftshift(double[][] in)
    • vsnr

      private void vsnr()
    • find_best_csnrs

      private double find_best_csnrs(double Ce)
    • analyze_dst_img

      private double[] analyze_dst_img()
    • analyze_src_img

      private void analyze_src_img()
    • best_csnrs

      private double best_csnrs(double v_idx)
    • imdwt

      private double[][][][] imdwt(double[][] LL0, int num_levels)
    • DoTransformRows

      public void DoTransformRows(double[][] Buffer, double[][] SBuffer, double[][] DBuffer)
    • DoTransformCols

      public void DoTransformCols(double[][] Buffer, double[][] SBuffer, double[][] DBuffer)
    • Reconstruct

      private void Reconstruct(double[][][] bands, int num_scales)
    • DoUntransformCols

      private void DoUntransformCols(double[][] Buffer, double[][] SBuffer, double[][] DBuffer)
    • DoUntransformRows

      private void DoUntransformRows(double[][] Buffer, double[][] SBuffer, double[][] DBuffer)