예제 #1
0
QImage YoonEncryptor::encrypt(const QImage &src)
{
    auto result = src;
    if(result.height() > result.width())
        result = result.transformed(QTransform().rotate(90));

    QVector<int> seed = dividers(result.height());
    int **lookUpTable = createLUT(seed);
    QImage tempImage;
    int red,green,blue;
    QColor oldColor;
    for(int r = 0; r < K; r++){
        tempImage = result;
        int **mask = createMask(result.height());
        for(int i = 0; i < result.height(); i++){
            for(int j = 0; j < result.width(); j++){
                oldColor = tempImage.pixelColor(j, i);
                red   = oldColor.red()^mask[lookUpTable[i][j]][j];
                green = oldColor.green()^mask[lookUpTable[i][j]][j];
                blue  = oldColor.blue()^mask[lookUpTable[i][j]][j];
                result.setPixelColor(j, lookUpTable[i][j], QColor(red, green, blue));
            }
        }
        freeMemory(mask, result.height());
    }
    freeMemory(lookUpTable, result.height());

    if(result.height() > result.width())
        result = result.transformed(QTransform().rotate(-90));
    return result;
}
예제 #2
0
void runComa(int ch){
	
	p.ch = ch;							//darksusy channel

	c.name = "Coma"; 						
	c.z = 0.0232; 						//redshift
	c.rh = 0.415;						//halo radius Mpc
	c.B0 = 4.7;			
	//c.alpha = 1.0/3.0;			//	
	c.rcore = 0.291*mpc2cm;				//

	double rcm = c.rh * mpc2cm ; 
	double rmax = rconst(rcm);

	double mx_min = 300;
	double mx_max = 1000;
	double data;

	std::string channel;

	if(p.ch == 13){
		channel = "WW";
	}
	else if(p.ch == 15){
		channel = "ee";
	}
	else if(p.ch == 17){
		channel = "mumu";
	}
	else if(p.ch == 19){
		channel = "tt";
	}
	else if(p.ch == 25){
		channel = "bb";
	};

	
	std::ostringstream makefilename;
	makefilename << "061316_"<<c.name << "_NONZERO_" << channel << "_alpha_" <<c.alpha <<"TEST.txt" ;
	std::string filename = makefilename.str();
	std::ofstream file(filename.c_str());


	int n_mx = 15 ;//number of mx values used
/*
 p.mx = 500;
 createLUT();
 std::cout << Calc_sv(rmax)<<std::endl;*/
//createLUT();
//double rt = 6.9984/1000*mpc2cm;f
//std::cout << dndeeq(0.000511, rt)<<std::endl;

	for (int i = 0 ; i < n_mx + 1 ; ++i){

		// iteration timer start
		std::clock_t start;
		double duration;
		start = std::clock();
		int a ; 
		///////before algorithm

			p.mx = mx_min * ( exp(    (log(mx_max) - log(mx_min))/ n_mx * i));

			createLUT();
			data = Calc_sv(rmax);
			file << p.mx << "\t" <<  data <<std::endl;
			std::cout << "sv( " << p.mx << " ) = " << data << std::endl;

		////////after algorithm
		duration = (std::clock()  -  start)/(double) CLOCKS_PER_SEC;
		std::cout << i << "/"<< n_mx << " ";
		std::cout << p.ch << ", alpha = " << c.alpha << ", time = " << duration <<std::endl;


	};

//end runComa()
}