CPBD_test.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. %=====================================================================
  2. % File: CPBD_test.m
  3. % Original code written by Niranjan D. Narvekar
  4. % IVU Lab (http://ivulab.asu.edu)
  5. % Last Revised: October 2009 by Niranjan D. Narvekar
  6. %=====================================================================
  7. % Copyright Notice:
  8. % Copyright (c) 2009-2010 Arizona Board of Regents.
  9. % All Rights Reserved.
  10. % Contact: Lina Karam (karam@asu.edu) and Niranjan D. Narvekar (nnarveka@asu.edu)
  11. % Image, Video, and Usabilty (IVU) Lab, ivulab.asu.edu
  12. % Arizona State University
  13. % This copyright statement may not be removed from this file or from
  14. % modifications to this file.
  15. % This copyright notice must also be included in any file or product
  16. % that is derived from this source file.
  17. %
  18. % Redistribution and use of this code in source and binary forms,
  19. % with or without modification, are permitted provided that the
  20. % following conditions are met:
  21. % - Redistribution's of source code must retain the above copyright
  22. % notice, this list of conditions and the following disclaimer.
  23. % - Redistribution's in binary form must reproduce the above copyright
  24. % notice, this list of conditions and the following disclaimer in the
  25. % documentation and/or other materials provided with the distribution.
  26. % - The Image, Video, and Usability Laboratory (IVU Lab,
  27. % http://ivulab.asu.edu) is acknowledged in any publication that
  28. % reports research results using this code, copies of this code, or
  29. % modifications of this code.
  30. %
  31. % The code and our papers are to be cited in the bibliography as:
  32. %
  33. % N.D. Narvekar and L. J. Karam, "CPBD Sharpness Metric Software",
  34. % http://ivulab.asu.edu/Quality/CPBD
  35. %
  36. % N.D. Narvekar and L. J. Karam, "A No-Reference Perceptual Image Sharpness
  37. % Metric Based on a Cumulative Probability of Blur Detection,"
  38. % International Workshop on Quality of Multimedia Experience (QoMEX 2009),
  39. % pp. 87-91, July 2009.
  40. %
  41. % N. D. Narvekar and L. J. Karam, "An Improved No-Reference Sharpness Metric Based on the
  42. % Probability of Blur Detection," International Workshop on Video Processing and Quality Metrics
  43. % for Consumer Electronics (VPQM), http://www.vpqm.org, January 2010.
  44. %
  45. % DISCLAIMER:
  46. % This software is provided by the copyright holders and contributors
  47. % "as is" and any express or implied warranties, including, but not
  48. % limited to, the implied warranties of merchantability and fitness for
  49. % a particular purpose are disclaimed. In no event shall the Arizona
  50. % Board of Regents, Arizona State University, IVU Lab members, or
  51. % contributors be liable for any direct, indirect, incidental, special,
  52. % exemplary, or consequential damages (including, but not limited to,
  53. % procurement of substitute goods or services; loss of use, data, or
  54. % profits; or business interruption) however caused and on any theory
  55. % of liability, whether in contract, strict liability, or tort
  56. % (including negligence or otherwise) arising in any way out of the use
  57. % of this software, even if advised of the possibility of such damage.
  58. %
  59. clc;
  60. clear all;
  61. % image_path = input('Enter image folder path (absolute or relative to current directory): ','s');
  62. image_path = '';
  63. is_MOS = input('Are the subjective scores Mean Opinion Scores (MOS) and not Difference MOS (DMOS)? (enter Y or N): ','s');
  64. if(is_MOS == 'Y')
  65. i_is_mos = 1;
  66. elseif(is_MOS == 'N')
  67. i_is_mos = 0;
  68. else
  69. disp('Error: Please Enter Y or N. Try again.');
  70. return;
  71. end
  72. % data_file = input('Enter excel data file name with extension and path (e.g., data.xls): ','s');
  73. data_file = 'data.xls';
  74. [num, txt] = xlsread(data_file);
  75. image_number = txt(2:end,1);
  76. metric_cpbd = zeros(1,numel(image_number));
  77. for i = 1:numel(image_number)
  78. A = imread([image_path,char(image_number(i))]);
  79. A = rgb2gray(A);
  80. metric_cpbd(i) = CPBD_compute(A); %%%%%%%%%%%%%%%%%%%%%%%%%%
  81. disp([' image number ='])
  82. disp(i);
  83. end
  84. xlswrite(data_file, metric_cpbd', 'D2:D175');
  85. num = xlsread(data_file);
  86. std_dev = num(:,1);
  87. mos_scores = num(:,2);
  88. metric_cpbd = num(:,3);
  89. [r, rnonlinear, rspear, routlier, rmse, mae] = evaluate_metric_performance(metric_cpbd, mos_scores, std_dev, i_is_mos); %%%%%%%%%%%%%%%
  90. disp('Pearson Linear Correlation Coefficient');
  91. rnonlinear
  92. disp('Spearman Rank-Order Correlation Coefficient');
  93. rspear
  94. disp('Root Mean Squared Error (RMSE)');
  95. rmse
  96. disp('Mean Absolute Error (MAE)');
  97. mae
  98. disp('Outlier Ratio');
  99. routlier