问题
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