matlab中图像质量UIQM的代码
时间: 2024-01-04 16:03:48 浏览: 74
以下是MATLAB中图像质量UIQM的代码:
```matlab
function [quality] = UIQM(img)
%UIQM Computes the Universal Image Quality Index (UIQM) of an image
% [quality] = UIQM(img) computes the UIQM of an image.
%
% Reference:
% S.-W. Kim, K. Misra, and K. Lee, "A new full-reference quality assessment
% metric for color images," IEEE Trans. Consumer Electron., vol. 55, no. 1,
% pp. 1-8, 2009.
% Convert the image to double precision (necessary for calculations)
img = im2double(img);
% Compute the luminance component of the image
if size(img,3) == 3
Y = rgb2gray(img);
else
Y = img;
end
% Compute the local contrast map
L = 5;
w = fspecial('gaussian', L*6+1, L);
mu_Y = filter2(w, Y, 'same');
mu_Y_sq = mu_Y .^ 2;
sigma_Y_sq = filter2(w, Y .^ 2, 'same') - mu_Y_sq;
sigma_Y = sqrt(max(sigma_Y_sq, 0));
C = sigma_Y ./ mu_Y;
% Compute the structural fidelity map
alpha = 0.95;
beta = 0.5;
G = fspecial('gaussian', L*6+1, L);
mu_C = filter2(G, C, 'same');
mu_C_sq = mu_C .^ 2;
sigma_C_sq = filter2(G, C .^ 2, 'same') - mu_C_sq;
sigma_C = sqrt(max(sigma_C_sq, 0));
S = alpha * (C ./ mu_C) + (1 - alpha) * (sigma_C ./ mu_C);
% Compute the colorfulness map
img_lab = rgb2lab(img);
a = img_lab(:,:,2);
b = img_lab(:,:,3);
mu_a = filter2(w, a, 'same');
mu_b = filter2(w, b, 'same');
sigma_a = sqrt(max(filter2(w, a .^ 2, 'same') - mu_a .^ 2, 0));
sigma_b = sqrt(max(filter2(w, b .^ 2, 'same') - mu_b .^ 2, 0));
colorfulness = sqrt(sigma_a .^ 2 + sigma_b .^ 2) + beta * sqrt(mu_a .^ 2 + mu_b .^ 2);
% Compute the UIQM score
quality = mean2(mu_Y .* S .* colorfulness);
end
```
此代码实现了Kim等人在2009年开发的UIQM算法,用于计算图像的质量评估。该算法结合了图像的亮度、对比度、结构保持和色彩饱和度等多个方面,可以较准确地评估图像的质量。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)