注:本帖不对CCS软件安装、DSP工程建立及相关配置介绍。 上两篇中,我们介绍了LSB隐藏,然而顺序隐藏,信息极易抹去,故有采取随机间隔的方法对信息不在那么有序,首先得有随机间隔函数:
- //row为随机间隔像素行标
- //col为随机间隔像素列标
- //mrow为图像像素高度
- //mcol为像素宽度
- //count为信息数大小
- //key为rand函数的种子
- void randinterval(int *row, int *col, const int mrow, const int mcol, const int count, const int key)
- {
- double *a = malloc(count * sizeof(double));
- int r = 1, c = 1, i;
- int interval1, interval2;
- interval1 = mrow * mcol / count + 1;
- interval2 = interval1 - 2;
- if(interval2 == 0)
- {
- perror("载体太小不能将秘密信息隐藏进去!");
- exit(EXIT_FAILURE);
- }
- srand(key);
- for(i = 0; i < count; i++)
- {
- a[i] = rand() / 32768.0;
- row[i] = 0;
- col[i] = 0;
- }
- row[1] = r;
- col[1] = c;
- for(i = 1; i < count; i ++)
- {
- if(a[i] > 0.5)
- c = c + interval1;
- else
- c = c + interval2;
- if(c > mcol)
- {
- r = r + c / mcol;
- if(r > mrow)
- {
- perror("载体太小不能将秘密信息隐藏进去!");
- exit(EXIT_FAILURE);
- }
- c = c % mcol;
- if(c == 0)
- c = 1;
- }
- row[i] = r;
- col[i] = c;
- }
- free(a);
- }
复制代码
有了以上函数,仅需要对之前的函数稍加修改即可:
运行结果: |