图像置乱之评价图像置乱度算法的选择

@浪子帅哥
//计算置乱度函数， BlockSize为分块大小
double ScramblingDegree(int **imgdata)
{
//计算分块数
int SplRows, SplCols, len = 0;
if((deminfo.nrows % BlockSize) > 0)
{
SplRows = deminfo.nrows / BlockSize + 1;
}
if((deminfo.ncols % BlockSize) > 0)
{
SplCols = deminfo.ncols / BlockSize + 1;
}
//计算分块高程均值，存入Block数组
int BlockNum = (SplRows * SplCols);
double *Block;
double Block_FC = 0, Sum = 0;
Block = (double*)malloc(BlockNum * sizeof(double));
for(int m = 0; m < SplRows; m++)
{
for(int n = 0; n < SplCols; n++)
{
int count = 0;
for(int i = (deminfo.nrows -1) - (BlockSize) * m; i > (deminfo.nrows - BlockSize * (m + 1)) && i >= 0; i--)
{
for(int j = (deminfo.ncols -1) - (BlockSize) * m; j > (deminfo.ncols - BlockSize * (m + 1)) && j >= 0; j--)
{
Sum += imgdata[i][j], count++;
}
}
Block[len++] = Sum / double(count);
}
}

//计算所有分块均值的均值
for(int i = 0; i < SplRows * SplCols; i++)
{
Block_FC += Block[i];
}
Block_FC /= (SplRows * SplCols), Sum = 0;

//计算所有分块均值的方差
for(int i = 0; i < SplRows * SplCols; i++)
{
Sum += pow((Block[i] - Block_FC),2);
}

return Sum / (SplRows * SplCols);
}
double MainScramble(int **imgdata1, int **imgdata2)
{
double org, end, scram;
org = ScramblingDegree(imgdata1);
end = ScramblingDegree(imgdata2);
scram = 1 - end / org;
return scram;
}


1 0.3829
2 0.4617
3 0.6325