⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newscramdegree.c

📁 图像置乱代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	/*fprintf(fp1, "DSF(%2d)=%f, GSF(%2d)=%f, DDR(%2d)=%f,  Ds(%2d)=%f\n", k+1, DSF, k+1, GSF, k+1, DDR,k+1, Ds);*//*----------------------------------------------------
	DSF = getDSF(dest_r, dest_c, height, width);
	GSF = getGSF(srcIm, destIm, height, width);
	Ds = DSF * GSF;	printf( "ds(%d) =  %f\n", k+1, Ds);	fprintf(fp, "%d  %f  %f  %f\n", k+1,Ds, DSF,GSF);
	//fprintf(fp1, "Ds(%2d)=%f\n", k+1, Ds);	//fprintf(fp1, "%d   %f  %f  %f   %f\n", k+1, DSF, GSF, DDR, Ds);	//fclose(fp2);/*---------------------------------------------------	strcpy(fnhistg,filename);	gcvt(k+1,5,string);	strcat(fnhistg,"_histg_");	strcat(fnhistg,string);	strcat(fnhistg,".txt");	fp2 = fopen(fnhistg,"wb");	for(i = 0;i < MASK_size; i ++)		if(rp[i]>0.000001)			fprintf(fp2,"%d  %f \n",i,rp[i]);	fclose(fp2);/*---------------------------------------------------*/
	}//end of iterative operation
	//fclose(fp);	//fclose(fp2);	//fclose(fp3);	fclose(fp4);
/*-----------------------------------------------------
	printf("\n");
	int neighbor_n = MASK_width*MASK_width;	double p[neighbor_n];	for(i = 0;i < neighbor_n; i ++)		p[i] = 1;	p[0] = neighbor_n;	for(j = 2-neighbor_n;j <= 0; j ++)		p[0] = p[0]*(width*width - neighbor_n + j)/(width*width + j);	p[0] = p[0]/(width*width + 1-neighbor_n); 	for(i = 1;i < neighbor_n; i ++)	{		for(j = 1 ; j < i; j ++)			p[i] = p[i]*(neighbor_n - j);		for(j = i+2-neighbor_n; j <= 0;j ++)			p[i] = p[i]*(width*width - neighbor_n + j)/(width*width + j-i);		p[i] = p[i]/(width*width + 1-neighbor_n); 	}	for(i = 0;i < neighbor_n; i ++)		printf("p[%d] = %f\n",i,p[i]);*/
	free_int_matrix(trans_r, height);
	free_int_matrix(trans_c, height);
	free_int_matrix(tmp_r, height);
	free_int_matrix(tmp_c, height);
	free_int_matrix(dest_r, height);
	free_int_matrix(dest_c, height);	free_int_matrix(src_r, height);
	free_int_matrix(src_c, height);	free_int_matrix(count, height);
	free_int_matrix(countn, height);	free_int_vector(count_histg);		free_int_vector(count_histgn);/*----------------------------------------------------------------------------------*/	fp2 = fopen("m.txt","wb");	fprintf(fp2,"%f  0   %f  0   %f  0\n",MEAN_n,ed1+MEAN_n,ed2+MEAN_n);	//fprintf(fp2,"%f  %f  %f  %f  %f  %f\n",MEAN_n,(p[(int)MEAN_n]+p[(int)MEAN_n+1])/2,ed1+MEAN_n,(p[(int)(ed1+MEAN_n)]+p[(int)(ed1+MEAN_n)+1])/2,ed2+MEAN_n,(p[(int)(ed2+MEAN_n)]+p[(int)(ed2+MEAN_n)+1])/2);	fclose(fp2);	fp2 = fopen("rp.txt","wb");	for(i = 0;i < MASK_size; i ++)		if(rp[i]>0.000001)			fprintf(fp2,"%d  %f \n",i,rp[i]);	fclose(fp2);/*--------------------------------------gnuplot-----------------------------------*/	strcpy(fnpng,filename);	strcat(fnpng,".png");	gnuplot_ctrl *hm;	hm = gnuplot_init();	gnuplot_cmd(hm,"set xlabel 'Numbers of old neighbor'");	gnuplot_cmd(hm,"set ylabel 'Probability'");	//gnuplot_cmd(hm,"plot '%s' using 1:2  with linespoints,'%s' using 1:2  title '50% E' with linespoints,'%s' using 3:4 title  '25%' with linespoints,'%s' using 5:6 title '75%' with linespoints", fname,"m.txt","m.txt","m.txt");	//gnuplot_cmd(hm,"plot '%s' using 1:2  with linespoints,'%s' using 1:2 title 'E' with lines,'%s' using 3:4 title 'ed1' with lines,'%s' using 5:6 title 'ed2' with lines,'%s' using 1:2  with linespoints", fname,"m.txt","m.txt","m.txt","rp.txt");	gnuplot_cmd(hm,"plot '%s' using 1:2  with linespoints title 'Theoretical Value','%s' using 1:2 title 'E' with lines,'%s' using 1:2  with linespoints title '%s'", fname,"m.txt","rp.txt",filename);	//gnuplot_cmd(hm,"set label 1 'mean' at %d,0 top",mean);	gnuplot_cmd(hm,"set term png");	gnuplot_cmd(hm,"set output '%s' ",fnpng);	gnuplot_cmd(hm,"replot");/*-------------------------------points-------------------------------------------	strcpy(fnpng,filename);	strcat(fnpng,"_points.png");	gnuplot_ctrl *hmp;	hmp = gnuplot_init();	gnuplot_cmd(hmp,"plot '%s' using 1:2  with points title '%s'", "points.txt",filename);	gnuplot_cmd(hmp,"set term png");	gnuplot_cmd(hmp,"set output '%s' ",fnpng);	gnuplot_cmd(hmp,"replot");/*----------------------------DSF--GSF----DS----------------------------------------	strcpy(fndspng,fnds);	strcat(fndspng,".png");	gnuplot_ctrl *hds;	hds = gnuplot_init();	gnuplot_cmd(hds,"plot '%s' using 1:2  with linespoints title '%s','%s' using 1:3  with linespoints title 'DSF','%s' using 1:4  with linespoints title 'GSF'", fndstxt,fnds, fndstxt, fndstxt);	gnuplot_cmd(hds,"set term png");	gnuplot_cmd(hds,"set output '%s' ",fndspng);	gnuplot_cmd(hds,"replot");/*--------------------------------------------------------------------------*/	char fpng[64];/*--------------------------------------------------------------------------	strcpy(fpng,filename);	strcat(fpng,"_ED.png");	gnuplot_ctrl *hED;	hED = gnuplot_init();	gnuplot_cmd(hED,"set xlabel 'Numbers of old neighbor'");	gnuplot_cmd(hED,"set ylabel 'Probability'");	gnuplot_cmd(hED,"set yrange [0,1]");	gnuplot_cmd(hED,"plot '%s' using 1:4 title 'ED' with linespoints", filename3);	gnuplot_cmd(hED,"set term png");	gnuplot_cmd(hED,"set output '%s' ",fpng);	gnuplot_cmd(hED,"replot");	strcpy(fpng,filename);	strcat(fpng,"_D.png");	gnuplot_ctrl *hD;	hD = gnuplot_init();	gnuplot_cmd(hD,"plot '%s' using 1:5 title 'D' with linespoints", filename3);	gnuplot_cmd(hD,"set term png");	gnuplot_cmd(hD,"set output '%s' ",fpng);	gnuplot_cmd(hD,"replot");	strcpy(fpng,filename);	strcat(fpng,"_S.png");	gnuplot_ctrl *hS;	hS = gnuplot_init();	gnuplot_cmd(hS,"plot '%s' using 1:6 title 'S' with linespoints", filename3);	gnuplot_cmd(hS,"set term png");	gnuplot_cmd(hS,"set output '%s' ",fpng);	gnuplot_cmd(hS,"replot");	strcpy(fpng,filename);	strcat(fpng,"_ED_D.png");	gnuplot_ctrl *h;	h = gnuplot_init();	//gnuplot_cmd(h,"plot '%s' using 1:6 title 'S' with linespoints,'%s' using 1:8 title '1-(ED+D)/2' with linespoints", filename3,filename3);	gnuplot_cmd(h,"plot '%s' using 1:8 title '1-(ED+D)/2' with linespoints",filename3);	gnuplot_cmd(h,"set term png");	gnuplot_cmd(h,"set output '%s' ",fpng);	gnuplot_cmd(h,"replot");/*--------------------------------------------------------------------------*/	gnuplot_ctrl *hmulti;	strcpy(fpng,filename);	strcat(fpng,"_multi.png");	hmulti = gnuplot_init();	gnuplot_cmd(hmulti,"set term png");	gnuplot_cmd(hmulti,"set output '%s' ",fpng);	gnuplot_cmd(hmulti,"set xlabel 'Numbers of old neighbor'");	gnuplot_cmd(hmulti,"set ylabel 'Probability'");	gnuplot_cmd(hmulti,"set yrange [0:1]");	gnuplot_cmd(hmulti,"set multiplot");	gnuplot_cmd(hmulti,"set origin 0.0,0.5");	gnuplot_cmd(hmulti,"set size 0.5,0.5");	gnuplot_cmd(hmulti,"plot '%s' using 1:4 title 'ED' with linespoints", filename3);	gnuplot_cmd(hmulti,"set origin 0.5,0.5");	gnuplot_cmd(hmulti,"set size 0.5,0.5");	gnuplot_cmd(hmulti,"plot '%s' using 1:5 title 'D' with linespoints", filename3);	gnuplot_cmd(hmulti,"set origin 0.0,0.0");	gnuplot_cmd(hmulti,"set size 0.5,0.5");	gnuplot_cmd(hmulti,"plot '%s' using 1:6 title 'S' with linespoints", filename3);	gnuplot_cmd(hmulti,"set origin 0.5,0.0");	gnuplot_cmd(hmulti,"set size 0.5,0.5");	gnuplot_cmd(hmulti,"plot '%s' using 1:8 title '1-(ED+D)/2' with linespoints", filename3);	gnuplot_cmd(hmulti,"unset multiplot");	gnuplot_cmd(hmulti,"reset");/*--------------------------------------------------------------------------	gnuplot_ctrl *hmulti;	//strcpy(fpng,filename);	//strcat(fpng,"_multi.png");	hmulti = gnuplot_init();	//gnuplot_cmd(hmulti,"set term png");	//gnuplot_cmd(hmulti,"set output '%s' ",fpng);	gnuplot_cmd(hmulti,"set xlabel 'Numbers of old neighbor'");	gnuplot_cmd(hmulti,"set ylabel 'Probability'");	gnuplot_cmd(hmulti,"set yrange [0:1]");	//gnuplot_cmd(hmulti,"set multiplot");	//gnuplot_cmd(hmulti,"set origin 0.0,0.5");	//gnuplot_cmd(hmulti,"set size 0.5,0.5");	gnuplot_cmd(hmulti,"plot '%s' using 1:4 title 'ED' with linespoints,'%s' using 1:5 title 'D' with linespoints,'%s' using 1:6 title 'S' with linespoints,'%s' using 1:8 title '1-(ED+D)/2' with linespoints", filename3,filename3,filename3,filename3);	//gnuplot_cmd(hmulti,"set origin 0.5,0.5");	//gnuplot_cmd(hmulti,"set size 0.5,0.5");	//gnuplot_cmd(hmulti,"plot '%s' using 1:5 title 'D' with linespoints", filename3);	//gnuplot_cmd(hmulti,"set origin 0.0,0.0");	//gnuplot_cmd(hmulti,"set size 0.5,0.5");	//gnuplot_cmd(hmulti,"plot '%s' using 1:6 title 'S' with linespoints", filename3);	//gnuplot_cmd(hmulti,"set origin 0.5,0.0");	//gnuplot_cmd(hmulti,"set size 0.5,0.5");	//gnuplot_cmd(hmulti,"plot '%s' using 1:8 title '1-(ED+D)/2' with linespoints", filename3);	//gnuplot_cmd(hmulti,"unset multiplot");	//gnuplot_cmd(hmulti,"reset");/*--------------------------------------------------------------------------*//*       use gnuplot to plot      Dec 8,2006*//*--------------------------------------------------------------------------	char filenamepng[64];	gnuplot_ctrl *h,*h1,*h2,*h3;	strcpy(filenamepng,filename);	strcat(filenamepng,"_mean_n.png");	h = gnuplot_init();	gnuplot_cmd(h,"plot '%s' using 1:2 title 'mean_n' with linespoints,'%s' using 1:3 title 'ed1+ed2' with linespoints", filename3,filename3);	gnuplot_cmd(h,"set term png");	gnuplot_cmd(h,"set output '%s' ",filenamepng);	gnuplot_cmd(h,"replot");	h2 = gnuplot_init();	gnuplot_cmd(h2,"plot '%s' using 1:4 title 'fabs(red1+red2)/(MASK_size-1 - MEAN_n)' with linespoints", filename3);	//gnuplot_cmd(h2,"plot '%s' using 1:4 title 'fabs(red1+red2)/(MASK_size-1 - MEAN_n)' with linespoints,'%s' using 1:5 title '1-fabs(red1+red2)/(MASK_size-1 - MEAN_n)' with linespoints", filename3,filename3);	//gnuplot_cmd(h2,"plot '%s' using 1:4 title 'fabs(red1+red2)/ed2' with linespoints", filename3);/*---------------------------------------------------------------------------------	strcpy(filenamepng,filename);	strcat(filenamepng,"_times012.png");	h1 = gnuplot_init();	gnuplot_cmd(h1,"plot '%s' using 1:2 title '0' with linespoints, '%s' using 1:3 title '1' with linespoints,'%s' using 1:4 title '2' with linespoints,'%s' using 1:5 title '3' with linespoints,'%s' using 1:6 title '4' with linespoints", filename2,filename2,filename2,filename2,filename2);	gnuplot_cmd(h1,"set term png");	gnuplot_cmd(h1,"set output '%s' ",filenamepng);	gnuplot_cmd(h1,"replot");	//gnuplot_cmd(h,"pause -1");	//gnuplot_close(h);/*----------------------------------------------------------------	h3 = gnuplot_init();	gnuplot_cmd(h3,"plot '%s' using 1:2 title 'n0' with linespoints, '%s' using 1:3 title '1' with linespoints,'%s' using 1:4 title '2' with linespoints,'%s' using 1:5 title '3' with linespoints,'%s' using 1:6 title '4' with linespoints", filename4,filename4,filename4,filename4,filename4);/*--------------------------------------------------------------------------*/
}static void scan_proc(void){    scan_files(directory_name,file_name);    tw_sglobal_reset(pdir);    tw_sglobal_reset(pfile);}
static void tool_proc(void)
{
    static int x = 100, y = 200;
    static int xr = 0, yr = 0;

    tv_tool(x+xr, y+yr);
    xr += 50;
    yr += 10;
    if (x+xr>700)
    {
       xr = yr = 0;
       y += 50;
    }
    if (y>400) y = 200;
}

static void mono_tool_proc(void)
{
    mono_tool(50, 50);
}

/*___________________ Tool creation ___________________*/
void im_scram_new_tool(int x, int y)
{
	static void *tool = NULL;
	if (tool)
	{
		tw_show_tool(tool);
		return;
	}    	/* Initialise pathname from environment variable (or #define) */    	(void) environ_pathname_get(directory_name, file_name,				"TINA_IMAGE_DEFAULT",				"/home/wzz/newimscramdegree/result/newscramdegree/Lena.bmp");
	tool = (void *)tw_tool("New image scrambling degree", x, y);
	/*---------------------------*/
	tw_label("Display");
	tw_button("New Tvtool", tool_proc, NULL);
	tw_label("        File i/o");
	tw_button("Mono", mono_tool_proc, NULL);	/*---------------------------*/  	tw_newrow();  	pdir = (void *) tw_sglobal("Directory:", directory_name, 32);    	tw_button("scan", scan_proc, NULL);  	tw_newrow();  	pfile = (void*) tw_sglobal("File:", file_name, 32);	/*---------------------------*/
	tw_newrow();
	tw_choice("Scrambling Method:", scram_choice_proc, 0,\
              "Fibonacci", "Arnold", "QATLIG", "Hilbert", "Zigzag", "Convey", "GrayCode", "Baker", "Logistic", "Random",NULL);
	tw_newrow();
	tw_iglobal("Transform times=", &n_scram, 10);
	tw_iglobal("Mask = ", &MASK_width, 5);
	tw_button("get Srambling Degree", scram_proc, NULL);
	tw_newrow();

	tw_newrow();
	tw_end_tool();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -