#include <vector>
// 擋髡綑� 萄蝌� 擋頓徹璃� 頡 媲曉麂瘢畫� � 頡 閑暸慢畫� 縝褕�-瘟
const int sizeH = 8;
const int sizeW = 8;
// 蜻曄-� 憐慮瘢 頡 亭曇衝�
void corr(std::vector<BYTE> *p_in1, std::vector<BYTE> *p_in2,
int ind_hor1, int ind_ver1,
float mean_val1, float mean_val2, int width, float *out)
{
float val(0);
for(int j = ind_ver1; j < ind_ver1 + sizeH - 1; j++)
for(int i = ind_hor1; i < ind_hor1 + sizeW -1; i++)
val += ((*p_in1)[j*width + i] - mean_val1)
* ((*p_in2)[j*width + i] - mean_val2);
*out = val / (sizeH * sizeW);
}
// 溘縉綑縊�
void disp(std::vector<BYTE> *p_in,
int ind_hor1, int ind_ver1,
float mean_val, int width, float *out)
{
float val(0);
for(int j = ind_ver1; j < ind_ver1 + sizeH - 1; j++)
for(int i = ind_hor1; i < ind_hor1 + sizeW - 1; i++)
val += ((*p_in)[j*width + i] - mean_val) * ((*p_in)[j*width + i] - mean_val);
*out = val / (sizeH * sizeW);
}
//影�. 蝸彰痢徹
void mean(std::vector<BYTE> *p_in,
int ind_hor1, int ind_ver1,
int width, float *out)
{
float val(0);
for(int j = ind_ver1; j < ind_ver1 + sizeH - 1; j++)
for(int i = ind_hor1; i < ind_hor1 + sizeW -1; i++)
val += (*p_in)[j*width + i];
*out = val / (sizeH * sizeW);
}
// 熱錨誅粵徹 MSSIM 慮錙溜� 縝蓊蠹�嚼廈 蝌熱
void getMSSIM(std::vector<BYTE> *p_in1, std::vector<BYTE> *p_in2,
int width, int height, float *MSSIM)
{
const float K1 = 0.01f; // K1, K2 << 1
const float K2 = 0.03f; // 蜻瘡錶瘢� 獗螂錨溘撲� 溫� 頑滓璃� C1 � C2
// 蜻瘡錶瘢� 溫� C1 � C2; (溘熱憂雛縈慷 溘痣蝨衝 愿慮獗璃� 震蜴粱筮);
// 255 溫� 8 菊�, �.�. 愿慮��粳 蒙誅毚 蜻憫衝粵雕 褕滇鼻瘟
const int L_const = 255;
float mean1(0), mean2(0), disp1(0), disp2(0), correl(0);
float SSIM(0); // SSIM 蜻璀擇錮蝶� 萄蝌�
// 蜻瘡錶瘢� 蜥摘綑�� MSSIM
const float C1 = (K1*L_const) * (K1*L_const);
const float C2 = (K2*L_const) * (K2*L_const);
const float C3 = C2/2;
// 縝羲琵���徹 蜥摘綑�� SSIM
float l(0); // luminance ecomparison
float c(0); // contrast comparison
float s(0); // structure comparison
float l_out(0), c_out(0), s_out(0);
for(int i = 0; i < height - sizeH; i++)
for(int j = 0; j < width - sizeW; j++)
{
mean(p_in1, j, i, width, &mean1);
mean(p_in2, j, i, width, &mean2);
disp(p_in1, j, i, mean1, width, &disp1);
disp(p_in2, j, i, mean2, width, &disp2);
corr(p_in1, p_in2, j, i, mean1, mean2, width, &correl);
l = (2*mean1*mean2 + C1) / (mean1*mean1 + mean2*mean2 + C1);
c = (2*sqrt(disp1*disp2) + C2) / (disp1 + disp2 + C2);
s = (correl + C3) / (sqrt(disp1*disp2) + C3);
l_out += l;
c_out += c;
s_out += s;
SSIM += l*c*s;
// SSIM += (2*mean1*mean2 + C1)*(2*correl + C2)/((sqr(mean1) + sqr(mean2) + C1)*(disp1 + disp2 + C2));
}
l_out = l_out / ((height - sizeH) * (width - sizeW));
c_out = c_out / ((height - sizeH) * (width - sizeW));
s_out = s_out / ((height - sizeH) * (width - sizeW));
*MSSIM = SSIM / ((height - sizeH) * (width - sizeW));
}
没有合适的资源?快使用搜索试试~ 我知道了~
MSSIM.zip_Measure Images_distortion_image quality_mean opinion s
共1个文件
h:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 107 浏览量
2022-09-24
14:35:12
上传
评论
收藏 1KB ZIP 举报
温馨提示
Source code of the MSSIM (Mean Structure Similitary Index). MSSIM is a measure of distortion static images. It s comparing distorted image with reference image and as the result return value between 0 and 1. The quality criteria is one of the most closer to MOS mean opinion score of image distortion.
资源推荐
资源详情
资源评论
收起资源包目录
MSSIM.zip (1个子文件)
MSSIM.h 3KB
共 1 条
- 1
资源评论
四散
- 粉丝: 65
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功