资源简介

程序利用了Cat Map来做图像像素位置的置乱,之后再利用Logistic映射来做像素位置的改变。并且还提供计算NPCR与UACI的方法。

资源截图

代码片段和文件信息

#include “Bitmap.h“
#include “Math.h“

void NPCR()
{
char file1[50]=“D:\\Experiment\\image\\baboon_cipher1.bmp“;
char file2[50]=“D:\\Experiment\\image\\baboon_cipher2.bmp“;
Bitmap *bmp1 = (Bitmap*)malloc(sizeof(Bitmap));
Bitmap *bmp2 = (Bitmap*)malloc(sizeof(Bitmap));


int ij;
int temp=0temp1=0temp2=0temp3=0;
int size=512*512;
double npcr=0npcr1=0npcr2=0npcr3=0;


load_bitmap(file1bmp1);
load_bitmap(file2bmp2);

for(i=0;iheight;i++)
for(j=0;jwidth;j++)
{
if(bmp1->matrix3[0][i][j]!=bmp2->matrix3[0][i][j])
temp1++;
if(bmp1->matrix3[1][i][j]!=bmp2->matrix3[1][i][j])
temp2++;
if(bmp1->matrix3[2][i][j]!=bmp2->matrix3[2][i][j])
temp3++;

if(bmp1->matrix3[0][i][j]!=bmp2->matrix3[0][i][j]||bmp1->matrix3[1][i][j]!=bmp2->matrix3[1][i][j]||bmp1->matrix3[2][i][j]!=bmp2->matrix3[2][i][j])
{
//printf(“ni ma bi\n“);
temp=temp+1;
}
}

npcr=temp*1.0/size;
npcr1=temp1*1.0/size;
npcr2=temp2*1.0/size;
npcr3=temp3*1.0/size;

printf(“The NPCR is %fNPCR1 is%fNPCR2 is%fNPCR3 is%f\n“npcrnpcr1npcr2npcr3);

/* temp=temp1=temp2=temp3=0;
npcr=npcr1=npcr2=npcr3=0;

for(i=bmp1->height/2;iheight;i++)
for(j=0;jwidth;j++)
{
if(bmp1->matrix3[0][i][j]!=bmp2->matrix3[0][i][j])
temp1++;
if(bmp1->matrix3[1][i][j]!=bmp2->matrix3[1][i][j])
temp2++;
if(bmp1->matrix3[2][i][j]!=bmp2->matrix3[2][i][j])
temp3++;

if(bmp1->matrix3[0][i][j]!=bmp2->matrix3[0][i][j]||bmp1->matrix3[1][i][j]!=bmp2->matrix3[1][i][j]||bmp1->matrix3[2][i][j]!=bmp2->matrix3[2][i][j])
{
//printf(“ni ma bi\n“);
temp=temp+1;
}
}

npcr=temp*1.0/size*2;
npcr1=temp1*1.0/size*2;
npcr2=temp2*1.0/size*2;
npcr3=temp3*1.0/size*2;

printf(“The NPCR is %fNPCR1 is%fNPCR2 is%fNPCR3 is%f\n“npcrnpcr1npcr2npcr3);
*/
free_bitmap(bmp1);
free_bitmap(bmp2);
}
void UACI()
{
char file1[50]=“D:\\Experiment\\image\\baboon_cipher1.bmp“;
char file2[50]=“D:\\Experiment\\image\\baboon_cipher2.bmp“;
Bitmap *bmp1 = (Bitmap*)malloc(sizeof(Bitmap));
Bitmap *bmp2 = (Bitmap*)malloc(sizeof(Bitmap));


int ij;
double temp=0temp1=0temp2=0temp3=0;
int size=512*512;
double uaci=0uaci1=0uaci2=0uaci3=0;


load_bitmap(file1bmp1);
load_bitmap(file2bmp2);

for(i=0;iheight;i++){
for(j=0;jwidth;j++)
{
temp1+=abs(bmp1->matrix3[0][i][j]-bmp2->matrix3[0][i][j])*1.0/255;
temp2+=abs(bmp1->matrix3[1][i][j]-bmp2->matrix3[1][i][j])*1.0/255;
temp3+=abs(bmp1->matrix3[2][i][j]-bmp2->matrix3[2][i][j])*1.0/255;
temp+=abs(bmp1->matrix3[0][i][j]*pow(216)+bmp1->matrix3[1][i][j]*pow(28)+bmp1->matrix3[0][i][j]-
bmp2->matrix3[0][i][j]*pow(216)+bmp2->matrix3[1][i][j]*pow(28)+bmp2->matrix3[0][i][j])*1.0/(pow(224)-1);
}
}
printf(“The temp is%f is%f is%f\n“temp1temp2temp3);

uaci=temp*1.0/size;
uaci1=temp1*1.0/size;
uaci2=temp2*1.0/size;
ua

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      39936  2011-07-11 10:03  MyExperiment\Debug\MyExperiment.exe

     文件     392924  2011-07-11 10:03  MyExperiment\Debug\MyExperiment.ilk

     文件     453632  2011-07-11 10:03  MyExperiment\Debug\MyExperiment.pdb

     文件       3111  2011-03-15 08:08  MyExperiment\MyExperiment\analysis.c

     文件       1551  2011-03-13 19:13  MyExperiment\MyExperiment\bitMap.h

     文件      12370  2011-03-15 08:08  MyExperiment\MyExperiment\Debug\analysis.obj

     文件       7122  2011-07-11 10:03  MyExperiment\MyExperiment\Debug\BuildLog.htm

     文件      11806  2011-07-11 10:03  MyExperiment\MyExperiment\Debug\encryption.obj

     文件      16150  2011-03-13 19:18  MyExperiment\MyExperiment\Debug\Loadimage.obj

     文件       7176  2011-07-11 10:03  MyExperiment\MyExperiment\Debug\main.obj

     文件         65  2011-07-11 10:03  MyExperiment\MyExperiment\Debug\mt.dep

     文件        663  2011-03-13 19:18  MyExperiment\MyExperiment\Debug\MyExperiment.exe.embed.manifest

     文件        728  2011-03-13 19:18  MyExperiment\MyExperiment\Debug\MyExperiment.exe.embed.manifest.res

     文件        621  2011-07-11 10:03  MyExperiment\MyExperiment\Debug\MyExperiment.exe.intermediate.manifest

     文件      60416  2011-07-11 10:03  MyExperiment\MyExperiment\Debug\vc90.idb

     文件      61440  2011-07-11 10:03  MyExperiment\MyExperiment\Debug\vc90.pdb

     文件       1968  2011-07-11 10:04  MyExperiment\MyExperiment\encryption.c

     文件       5887  2011-03-13 19:14  MyExperiment\MyExperiment\Loadimage.c

     文件        784  2011-07-11 10:03  MyExperiment\MyExperiment\main.c

     文件       4173  2011-03-14 11:03  MyExperiment\MyExperiment\MyExperiment.vcproj

     文件       1415  2011-07-11 10:04  MyExperiment\MyExperiment\MyExperiment.vcproj.lenovo-PC.lenovo.user

     文件     437248  2011-07-11 10:04  MyExperiment\MyExperiment.ncb

     文件        902  2011-03-13 19:11  MyExperiment\MyExperiment.sln

    ..A..H.     14848  2011-07-11 10:04  MyExperiment\MyExperiment.suo

     目录          0  2011-07-11 10:03  MyExperiment\MyExperiment\Debug

     目录          0  2011-05-29 18:03  MyExperiment\Debug

     目录          0  2011-07-11 10:04  MyExperiment\MyExperiment

     目录          0  2011-07-11 10:00  MyExperiment

----------- ---------  ---------- -----  ----

              1536936                    28

............此处省略1个文件信息

评论

共有 条评论