2

我正在尝试使用遵循正态分布的 opencv 创建一个 20X20 图像,我知道有一个 randn 函数可以让我做类似的事情,但是如果我打算嵌入一个我要创建的图像数据中的字符串?

4

1 回答 1

2

在这里查看均匀到高斯随机数: http: //www.design.caltech.edu/erik/Misc/Gaussian.html

如果您想为隐藏文本使用最后 2 个数据位(最低有效位),您需要在噪声图像中将它们设置为零。

接下来,创建 3 个图像:

Image noise, mask, textimg

AddNoiseTo(noise) // any kind of noise you want


SetEveryPixel(mask,unsigned char, 255-3)
CvAnd(noise,mask,noise) // to remove noise from the last 2 bits


cvPutText(textimg,yourtext,white);
CvNot(mask,mask) // invert the mask to remove data from the first 6 bits
CvAnd(textimg,mask,textimg) // filter the text image so only last 2 bits are kept
CvOr(noise,textimg,outputimg) // this will merge the two images

如果您想要 7 个数据位(更容易用肉眼看到文本),则从掩码中减去 127(二进制表示 7 个 1)而不是 3(二进制中的 11)。

于 2013-01-13T21:02:14.293 回答