Generate random BMP in CLI

六月ゝ 毕业季﹏ 提交于 2020-01-04 16:58:07

问题


I need a truly random BMP in order to test various lossy image compression algorithms. Ideally, this would not rely on any library and run in a Linux CLI.

It should generate a random BMP given a certain width and height.


回答1:


You can use ImageMagick (which is installed on most Linux distros by default) to generate an image of random noise like this:

convert -size 300x200 xc:gray +noise random out.bmp

where 300 is the width and 200 is the height (just examples).

Other types of noise are available, just run

convert -list noise

Output

Gaussian
Impulse
Laplacian
Multiplicative
Poisson
Random
Uniform

If the noise is too noisy ;-) for you, you can attenuate it with

convert -size 300x200 xc:gray -attenuate 0.5 +noise random out.bmp

for a 50% attenuation

Here are some examples of the different types:

Here are the corresponding distribution histograms:



来源:https://stackoverflow.com/questions/29011391/generate-random-bmp-in-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!