WS-PSNR不同投影格式的权重计算(ERP CMP)

计算权重,保存到txt中。

#include 
#include 
#include 
#include 

#include 
#include 

double getWeight(int form, int i, int j, int width, int height){
	double a;
	//======  format0: Equirectangular  =======  
	if (form == 0) {
		a = cos((j - (height / 2 - 0.5))*3.1415926 / height);
		return a;
	}
	else if (form == 5) {
		int ci, cj, r2;
		double d2;

		if (i < width / 4 && j < height / 3) {
			ci = width / 8;
			cj = height / 6;
		}
		else if (i < width / 4 && j >= height / 3 && j < 2 * height / 3) {
			ci = width / 8;
			cj = height / 2;
		}
		else if (i < width / 4 && j >= 2 * height / 3) {
			ci = width / 8;
			cj = 5 * height / 6;
		}
		else if (i >= width / 4 && i < width / 2 && j >= height / 3 && j < 2 * height / 3) {
			ci = 3 * width / 8;
			cj = height / 2;
		}
		else if (i >= width / 2 && i < 3 * width / 4 && j >= height / 3 && j < 2 * height / 3) {
			ci = 5 * width / 8;
			cj = height / 2;
		}
		else if (i > 3 * width / 4 && j >= height / 3 && j < 2 * height / 3) {
			ci = 7 * width / 8;
			cj = height / 2;
		}
		else {
			return 0;
		}
		d2 = (i + 0.5 - ci)*(i + 0.5 - ci) + (j + 0.5 - cj)*(j + 0.5 - cj);
		r2 = (width / 8)*(width / 8);
		a = 1.0 / ((1 + d2 / r2)*sqrt(1.0*(1 + d2 / r2)));
		return a;
	}
}

using namespace std;
int main(){
	double latWeight = 0;
	int height = 3072;
	int width = 4096;
	int form = 5;
	ofstream fout("data_cmpT.txt");

	for (int j = 0; j < height; j++) {
		for (int i = 0; i < width; i++) {
			latWeight = getWeight(form, i, j, width, height);
			fout << latWeight << ' ';
		}
		fout << '\t\n' << endl;
	}
	fout.close();
	return 0;
};

你可能感兴趣的:(全景视频质量评价)